KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sablecc > sablecc > exception > InternalException


1 /* This file is part of SableCC ( http://sablecc.org ).
2  *
3  * Copyright 2007 Etienne M. Gagnon <egagnon@j-meg.com>
4  * Copyright 2007 Patrick Pelletier <pp.pelletier@gmail.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.sablecc.sablecc.exception;
20
21 /**
22  * An internal exception is thrown when an unexpected error happens during the
23  * normal operation of the software. Ideally, this exception would never be
24  * thrown during execution. If it ever gets thrown, it is because a bug has been
25  * detected in the software.
26  * <p>
27  * In the source code of the software, this exception should be thrown whenever
28  * an unexpected situation is detected. For example, the exception should be
29  * thrown when some method argument is <code>null</code> and the method
30  * requires a non-null argument.
31  */

32 public class InternalException
33         extends RuntimeException JavaDoc {
34
35     /** Serial version identifier for serialization */
36     private static final long serialVersionUID = -4845566874186665747L;
37
38     /**
39      * Constructs a new internal exception with the provided error message.
40      *
41      * @param message
42      * the error message.
43      * @throws InternalException
44      * if the message is <code>null</code>.
45      */

46     public InternalException(
47             String JavaDoc message) {
48
49         super(message);
50
51         if (message == null) {
52             throw new InternalException("message may not be null");
53         }
54     }
55
56     /**
57      * Constructs a new internal exception with the provided error message and
58      * cause.
59      *
60      * @param message
61      * the error message.
62      * @param cause
63      * the cause.
64      * @throws InternalException
65      * if the message or the cause is <code>null</code>.
66      */

67     public InternalException(
68             String JavaDoc message,
69             Throwable JavaDoc cause) {
70
71         super(message, cause);
72
73         if (message == null) {
74             throw new InternalException("message may not be null");
75         }
76
77         if (cause == null) {
78             throw new InternalException("cause may not be null");
79         }
80     }
81
82 }
83
Popular Tags