KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > util > FatalExceptionError


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: FatalExceptionError.java,v 1.1 2005/07/13 11:09:06 slobodan Exp $
23  */

24
25
26
27
28 package com.lutris.util;
29
30 /*
31  * Class that encapsulates exceptions as runtime errors. This is used when an
32  * an exception is caught that really should be treated as a runtime error.
33  * This should only be used for exceptions that really should be treated as
34  * fatal errors; not as a way of by-passing Java error handling.
35  */

36 public class FatalExceptionError extends Error JavaDoc {
37     /**
38      * Encapsulated exception.
39      */

40     Exception JavaDoc except;
41
42     /**
43      * Constucts with an existing exception or error.
44      *
45      * @param except - Exception to encapsulate.
46      */

47     public FatalExceptionError (Exception JavaDoc except) {
48         this.except = except;
49     }
50
51     /**
52      * Get the exception that occured.
53      *
54      * @return A reference to the exception.
55      */

56     public Exception JavaDoc getException () {
57         return except;
58     }
59
60     /**
61      * Get the detail message of the encapsulate exception.
62      *
63      * @return The detail message
64      */

65     public String JavaDoc getMessage() {
66     return except.getMessage();
67     }
68
69     /**
70      * Get the localized message of the encapsulate exception.
71      *
72      * @return The detail message
73      */

74     public String JavaDoc getLocalizedMessage() {
75     return except.getLocalizedMessage();
76     }
77
78     /**
79      * Returns a string representation that includes this object and the
80      * encapsulated object.
81      *
82      * @return The string representation.
83      */

84     public String JavaDoc toString() {
85     String JavaDoc str = getClass().getName() + ": " +
86             except.getClass().getName();
87     String JavaDoc message = except.getMessage();
88
89         if (message == null)
90             return str;
91         return str + ": " + message;
92     }
93
94     /**
95      * Call the encapsulated object printStackTrack method with output to the
96      * standard error string.
97      */

98     public void printStackTrace() {
99         except.printStackTrace();
100     }
101
102     /**
103      * Call the encapsulated object printStackTrack method with output to a
104      * specified stream.
105      */

106     public void printStackTrace(java.io.PrintStream JavaDoc str) {
107         except.printStackTrace(str);
108     }
109
110     /**
111      * Call the encapsulated object printStackTrack method with output to a
112      * specified stream print writer.
113      */

114     public void printStackTrace(java.io.PrintWriter JavaDoc pw) {
115     except.printStackTrace(pw);
116     }
117 }
118
Popular Tags