01: /****************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one *
03: * or more contributor license agreements. See the NOTICE file *
04: * distributed with this work for additional information *
05: * regarding copyright ownership. The ASF licenses this file *
06: * to you under the Apache License, Version 2.0 (the *
07: * "License"); you may not use this file except in compliance *
08: * with the License. You may obtain a copy of the License at *
09: * *
10: * http://www.apache.org/licenses/LICENSE-2.0 *
11: * *
12: * Unless required by applicable law or agreed to in writing, *
13: * software distributed under the License is distributed on an *
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15: * KIND, either express or implied. See the License for the *
16: * specific language governing permissions and limitations *
17: * under the License. *
18: ****************************************************************/package org.apache.james.nntpserver;
19:
20: /**
21: * Exception Wrapper, like javax.servlet.ServletException.
22: * Purpose is to catch and wrap exceptions into unchecked NNTP specific.
23: * Protocol handler catches the exception and returns error info to client.
24: * Error Information is obtained by calling 'getMessage'
25: *
26: */
27: public class NNTPException extends RuntimeException {
28:
29: /**
30: * The encapsulated Throwable
31: */
32: private final Throwable t;
33:
34: /**
35: * Create an NNTPException with an error message and no
36: * encapsulated <code>Throwable</code>
37: *
38: * @param msg the error message for this exception
39: */
40: public NNTPException(String msg) {
41: super (msg);
42: this .t = null;
43: }
44:
45: /**
46: * Create an NNTPException with an error message and an
47: * encapsulated <code>Throwable</code>
48: *
49: * @param msg the error message for this exception
50: * @param t the encapsulated <code>Throwable</code>
51: */
52: public NNTPException(String msg, Throwable t) {
53: super (msg + ((t != null) ? ": " + t.toString() : ""));
54: this .t = t;
55: }
56:
57: /**
58: * Create an NNTPException with an
59: * encapsulated <code>Throwable</code>
60: *
61: * @param t the encapsulated <code>Throwable</code>
62: */
63: public NNTPException(Throwable t) {
64: super(t.toString());
65: this.t = t;
66: }
67: }
|