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