01 /*
02 * LuckyException.java
03 *
04 * Copyright (c) 1995-2010, The University of Sheffield. See the file
05 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06 *
07 * This file is part of GATE (see http://gate.ac.uk/), and is free
08 * software, licenced under the GNU Library General Public License,
09 * Version 2, June 1991 (in the distribution as file licence.html,
10 * and also available at http://gate.ac.uk/gate/licence.html).
11 *
12 * Valentin Tablan 06/2000
13 *
14 * $Id: LuckyException.java 12006 2009-12-01 17:24:28Z thomas_heitz $
15 */
16 package gate.util;
17 /**This exception is intended to be used in places where there definitely
18 *shouldn't be any exceptions thrown but the API requires us to catch some,
19 *eg: <code>
20 * try{
21 * if( a != null){
22 * a.doSomething();
23 * }
24 * }catch(NullPointerException npe){
25 * throw new LuckyException("I found a null pointer!");
26 * }
27 *</code>
28 *Of course the system will never require you to catch NullPOinterException as
29 *it derives from RuntimeException, but I couldn't come with a better example.
30 */
31 public class LuckyException extends RuntimeException {
32
33 /** Debug flag */
34 private static final boolean DEBUG = false;
35
36 /** Default constructor, creates a new execption with the default message */
37 public LuckyException() {
38 super(defaultMessage);
39 }
40
41 /** Creates a new exception with the provided message prepended to the default
42 * one on a separate line.
43 * @param message the uses message
44 */
45 public LuckyException(String message) {
46 super(message + "\n" + defaultMessage);
47 }
48
49 public LuckyException(String message, Throwable cause) {
50 super(message + "\n" + defaultMessage, cause);
51 }
52
53 public LuckyException(Throwable cause) {
54 super(defaultMessage, cause);
55 }
56
57 /**The default message carried by this type of exceptions*/
58 static String defaultMessage =
59 "Congratulations, you found the ONLY bug in GATE!";
60
61 }// end class LuckyException
|