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 package org.apache.james.nntpserver; 21 22 /*** 23 * Exception Wrapper, like javax.servlet.ServletException. 24 * Purpose is to catch and wrap exceptions into unchecked NNTP specific. 25 * Protocol handler catches the exception and returns error info to client. 26 * Error Information is obtained by calling 'getMessage' 27 * 28 */ 29 public class NNTPException extends RuntimeException { 30 31 /*** 32 * The encapsulated Throwable 33 */ 34 private final Throwable t; 35 36 /*** 37 * Create an NNTPException with an error message and no 38 * encapsulated <code>Throwable</code> 39 * 40 * @param msg the error message for this exception 41 */ 42 public NNTPException(String msg) { 43 super(msg); 44 this.t = null; 45 } 46 47 /*** 48 * Create an NNTPException with an error message and an 49 * encapsulated <code>Throwable</code> 50 * 51 * @param msg the error message for this exception 52 * @param t the encapsulated <code>Throwable</code> 53 */ 54 public NNTPException(String msg,Throwable t) { 55 super(msg+((t!=null)?": "+t.toString():"")); 56 this.t = t; 57 } 58 59 /*** 60 * Create an NNTPException with an 61 * encapsulated <code>Throwable</code> 62 * 63 * @param t the encapsulated <code>Throwable</code> 64 */ 65 public NNTPException(Throwable t) { 66 super(t.toString()); 67 this.t = t; 68 } 69 }