KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > shared > common > sanity > AssertFailure


1 /*
2
3    Derby - Class org.apache.derby.iapi.services.sanity.AssertFailure
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.shared.common.sanity;
23
24 import java.io.*;
25
26 /**
27  * AssertFailure is raised when an ASSERT check fails.
28  * Because assertions are not used in production code,
29  * are never expected to fail, and recovering from their
30  * failure is expected to be hard, they are under
31  * RuntimeException so that no one needs to list them
32  * in their throws clauses. An AssertFailure at the
33  * outermost system level will result in system shutdown.
34  **/

35 public class AssertFailure extends RuntimeException JavaDoc
36 {
37     private Throwable JavaDoc nestedException;
38
39     /**
40      * This constructor takes the pieces of information
41      * expected for each error.
42      *
43      * @param message the message associated with
44      * the error.
45      *
46      * @param nestedError errors can be nested together;
47      * if this error has another error associated with it,
48      * it is specified here. The 'outermost' error should be
49      * the most sever error; inner errors should be providing
50      * additional information about what went wrong.
51      **/

52     public AssertFailure(String JavaDoc message, Throwable JavaDoc nestedError)
53     {
54         super(message);
55         nestedException = nestedError;
56     }
57
58     /**
59      * This constructor expects no arguments or nested error.
60      **/

61     public AssertFailure(String JavaDoc message)
62     {
63         super(message);
64     }
65
66     public void printStackTrace() {
67         super.printStackTrace();
68         if (nestedException != null)
69             nestedException.printStackTrace();
70     }
71     public void printStackTrace(PrintStream s) {
72         super.printStackTrace(s);
73         if (nestedException != null)
74             nestedException.printStackTrace(s);
75     }
76     public void printStackTrace(PrintWriter s) {
77         super.printStackTrace(s);
78         if (nestedException != null)
79             nestedException.printStackTrace(s);
80     }
81 }
82
Popular Tags