01: /*
02:
03: Derby - Class org.apache.derby.iapi.services.sanity.AssertFailure
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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 {
36: private Throwable nestedException;
37:
38: /**
39: * This constructor takes the pieces of information
40: * expected for each error.
41: *
42: * @param message the message associated with
43: * the error.
44: *
45: * @param nestedError errors can be nested together;
46: * if this error has another error associated with it,
47: * it is specified here. The 'outermost' error should be
48: * the most sever error; inner errors should be providing
49: * additional information about what went wrong.
50: **/
51: public AssertFailure(String message, Throwable nestedError) {
52: super (message);
53: nestedException = nestedError;
54: }
55:
56: /**
57: * This constructor expects no arguments or nested error.
58: **/
59: public AssertFailure(String message) {
60: super (message);
61: }
62:
63: public void printStackTrace() {
64: super .printStackTrace();
65: if (nestedException != null)
66: nestedException.printStackTrace();
67: }
68:
69: public void printStackTrace(PrintStream s) {
70: super .printStackTrace(s);
71: if (nestedException != null)
72: nestedException.printStackTrace(s);
73: }
74:
75: public void printStackTrace(PrintWriter s) {
76: super.printStackTrace(s);
77: if (nestedException != null)
78: nestedException.printStackTrace(s);
79: }
80: }
|