View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
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   ****************************************************************/
19  
20  
21  
22  package org.apache.james.nntpserver;
23  
24  /**
25   * Exception Wrapper, like javax.servlet.ServletException.
26   * Purpose is to catch and wrap exceptions into unchecked NNTP specific. 
27   * Protocol handler catches the exception and returns error info to client.
28   * Error Information is obtained by calling 'getMessage'
29   *
30   */
31  public class NNTPException extends RuntimeException {
32  
33      /**
34       * The encapsulated Throwable
35       */
36      private final Throwable t;
37  
38      /**
39       * Create an NNTPException with an error message and no
40       * encapsulated <code>Throwable</code>
41       *
42       * @param msg the error message for this exception
43       */
44      public NNTPException(String msg) {
45          super(msg);
46          this.t = null;
47      }
48  
49      /**
50       * Create an NNTPException with an error message and an
51       * encapsulated <code>Throwable</code>
52       *
53       * @param msg the error message for this exception
54       * @param t the encapsulated <code>Throwable</code>
55       */
56      public NNTPException(String msg,Throwable t) {
57          super(msg+((t!=null)?": "+t.toString():""));
58          this.t = t;
59      }
60  
61      /**
62       * Create an NNTPException with an
63       * encapsulated <code>Throwable</code>
64       *
65       * @param t the encapsulated <code>Throwable</code>
66       */
67      public NNTPException(Throwable t) {
68          super(t.toString());
69          this.t = t;
70      }
71  }