View Javadoc

1   /************************************************************************
2    * Copyright (c) 2000-2006 The Apache Software Foundation.             *
3    * All rights reserved.                                                *
4    * ------------------------------------------------------------------- *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you *
6    * may not use this file except in compliance with the License. You    *
7    * may obtain a copy of the License at:                                *
8    *                                                                     *
9    *     http://www.apache.org/licenses/LICENSE-2.0                      *
10   *                                                                     *
11   * Unless required by applicable law or agreed to in writing, software *
12   * distributed under the License is distributed on an "AS IS" BASIS,   *
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
14   * implied.  See the License for the specific language governing       *
15   * permissions and limitations under the License.                      *
16   ***********************************************************************/
17  
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  }