jaroslav@52
|
1 |
/*
|
jaroslav@52
|
2 |
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
|
jaroslav@52
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
jaroslav@52
|
4 |
*
|
jaroslav@52
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
jaroslav@52
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
jaroslav@52
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
jaroslav@52
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
jaroslav@52
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
jaroslav@52
|
10 |
*
|
jaroslav@52
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
jaroslav@52
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
jaroslav@52
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
jaroslav@52
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
jaroslav@52
|
15 |
* accompanied this code).
|
jaroslav@52
|
16 |
*
|
jaroslav@52
|
17 |
* You should have received a copy of the GNU General Public License version
|
jaroslav@52
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
jaroslav@52
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
jaroslav@52
|
20 |
*
|
jaroslav@52
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
jaroslav@52
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
jaroslav@52
|
23 |
* questions.
|
jaroslav@52
|
24 |
*/
|
jaroslav@52
|
25 |
|
jaroslav@52
|
26 |
package java.lang;
|
jaroslav@52
|
27 |
|
jaroslav@52
|
28 |
/**
|
jaroslav@52
|
29 |
* The class {@code Exception} and its subclasses are a form of
|
jaroslav@52
|
30 |
* {@code Throwable} that indicates conditions that a reasonable
|
jaroslav@52
|
31 |
* application might want to catch.
|
jaroslav@52
|
32 |
*
|
jaroslav@52
|
33 |
* <p>The class {@code Exception} and any subclasses that are not also
|
jaroslav@52
|
34 |
* subclasses of {@link RuntimeException} are <em>checked
|
jaroslav@52
|
35 |
* exceptions</em>. Checked exceptions need to be declared in a
|
jaroslav@52
|
36 |
* method or constructor's {@code throws} clause if they can be thrown
|
jaroslav@52
|
37 |
* by the execution of the method or constructor and propagate outside
|
jaroslav@52
|
38 |
* the method or constructor boundary.
|
jaroslav@52
|
39 |
*
|
jaroslav@52
|
40 |
* @author Frank Yellin
|
jaroslav@52
|
41 |
* @see java.lang.Error
|
jaroslav@52
|
42 |
* @jls 11.2 Compile-Time Checking of Exceptions
|
jaroslav@52
|
43 |
* @since JDK1.0
|
jaroslav@52
|
44 |
*/
|
jaroslav@52
|
45 |
public class Exception extends Throwable {
|
jaroslav@52
|
46 |
static final long serialVersionUID = -3387516993124229948L;
|
jaroslav@52
|
47 |
|
jaroslav@52
|
48 |
/**
|
jaroslav@52
|
49 |
* Constructs a new exception with {@code null} as its detail message.
|
jaroslav@52
|
50 |
* The cause is not initialized, and may subsequently be initialized by a
|
jaroslav@52
|
51 |
* call to {@link #initCause}.
|
jaroslav@52
|
52 |
*/
|
jaroslav@52
|
53 |
public Exception() {
|
jaroslav@52
|
54 |
super();
|
jaroslav@52
|
55 |
}
|
jaroslav@52
|
56 |
|
jaroslav@52
|
57 |
/**
|
jaroslav@52
|
58 |
* Constructs a new exception with the specified detail message. The
|
jaroslav@52
|
59 |
* cause is not initialized, and may subsequently be initialized by
|
jaroslav@52
|
60 |
* a call to {@link #initCause}.
|
jaroslav@52
|
61 |
*
|
jaroslav@52
|
62 |
* @param message the detail message. The detail message is saved for
|
jaroslav@52
|
63 |
* later retrieval by the {@link #getMessage()} method.
|
jaroslav@52
|
64 |
*/
|
jaroslav@52
|
65 |
public Exception(String message) {
|
jaroslav@52
|
66 |
super(message);
|
jaroslav@52
|
67 |
}
|
jaroslav@52
|
68 |
|
jaroslav@52
|
69 |
/**
|
jaroslav@52
|
70 |
* Constructs a new exception with the specified detail message and
|
jaroslav@52
|
71 |
* cause. <p>Note that the detail message associated with
|
jaroslav@52
|
72 |
* {@code cause} is <i>not</i> automatically incorporated in
|
jaroslav@52
|
73 |
* this exception's detail message.
|
jaroslav@52
|
74 |
*
|
jaroslav@52
|
75 |
* @param message the detail message (which is saved for later retrieval
|
jaroslav@52
|
76 |
* by the {@link #getMessage()} method).
|
jaroslav@52
|
77 |
* @param cause the cause (which is saved for later retrieval by the
|
jaroslav@52
|
78 |
* {@link #getCause()} method). (A <tt>null</tt> value is
|
jaroslav@52
|
79 |
* permitted, and indicates that the cause is nonexistent or
|
jaroslav@52
|
80 |
* unknown.)
|
jaroslav@52
|
81 |
* @since 1.4
|
jaroslav@52
|
82 |
*/
|
jaroslav@52
|
83 |
public Exception(String message, Throwable cause) {
|
jaroslav@52
|
84 |
super(message, cause);
|
jaroslav@52
|
85 |
}
|
jaroslav@52
|
86 |
|
jaroslav@52
|
87 |
/**
|
jaroslav@52
|
88 |
* Constructs a new exception with the specified cause and a detail
|
jaroslav@52
|
89 |
* message of <tt>(cause==null ? null : cause.toString())</tt> (which
|
jaroslav@52
|
90 |
* typically contains the class and detail message of <tt>cause</tt>).
|
jaroslav@52
|
91 |
* This constructor is useful for exceptions that are little more than
|
jaroslav@52
|
92 |
* wrappers for other throwables (for example, {@link
|
jaroslav@52
|
93 |
* java.security.PrivilegedActionException}).
|
jaroslav@52
|
94 |
*
|
jaroslav@52
|
95 |
* @param cause the cause (which is saved for later retrieval by the
|
jaroslav@52
|
96 |
* {@link #getCause()} method). (A <tt>null</tt> value is
|
jaroslav@52
|
97 |
* permitted, and indicates that the cause is nonexistent or
|
jaroslav@52
|
98 |
* unknown.)
|
jaroslav@52
|
99 |
* @since 1.4
|
jaroslav@52
|
100 |
*/
|
jaroslav@52
|
101 |
public Exception(Throwable cause) {
|
jaroslav@52
|
102 |
super(cause);
|
jaroslav@52
|
103 |
}
|
jaroslav@52
|
104 |
|
jaroslav@52
|
105 |
/**
|
jaroslav@52
|
106 |
* Constructs a new exception with the specified detail message,
|
jaroslav@52
|
107 |
* cause, suppression enabled or disabled, and writable stack
|
jaroslav@52
|
108 |
* trace enabled or disabled.
|
jaroslav@52
|
109 |
*
|
jaroslav@52
|
110 |
* @param message the detail message.
|
jaroslav@52
|
111 |
* @param cause the cause. (A {@code null} value is permitted,
|
jaroslav@52
|
112 |
* and indicates that the cause is nonexistent or unknown.)
|
jaroslav@52
|
113 |
* @param enableSuppression whether or not suppression is enabled
|
jaroslav@52
|
114 |
* or disabled
|
jaroslav@52
|
115 |
* @param writableStackTrace whether or not the stack trace should
|
jaroslav@52
|
116 |
* be writable
|
jaroslav@52
|
117 |
* @since 1.7
|
jaroslav@52
|
118 |
*/
|
jaroslav@52
|
119 |
protected Exception(String message, Throwable cause,
|
jaroslav@52
|
120 |
boolean enableSuppression,
|
jaroslav@52
|
121 |
boolean writableStackTrace) {
|
jaroslav@52
|
122 |
super(message, cause, enableSuppression, writableStackTrace);
|
jaroslav@52
|
123 |
}
|
jaroslav@52
|
124 |
}
|