01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management;
10:
11: import java.io.PrintStream;
12: import java.io.PrintWriter;
13:
14: /**
15: * Thrown when an Error is thrown by the MBeanServer; it wraps the actual error thrown.
16: *
17: * @version $Revision: 1.7 $
18: */
19: public class RuntimeErrorException extends JMRuntimeException {
20: private static final long serialVersionUID = 704338937753949796L;
21:
22: /**
23: * @serial The nested error
24: */
25: private Error error;
26:
27: /**
28: * Creates a new RuntimeErrorException
29: *
30: * @param error The nested Error
31: */
32: public RuntimeErrorException(Error error) {
33: this .error = error;
34: }
35:
36: /**
37: * Creates a new RuntimeErrorException
38: *
39: * @param error The nested Error
40: * @param message The message
41: */
42: public RuntimeErrorException(Error error, String message) {
43: super (message);
44: this .error = error;
45: }
46:
47: public String getMessage() {
48: return super .getMessage() + " nested error is " + error;
49: }
50:
51: /**
52: * Returns the nested Error
53: */
54: public Error getTargetError() {
55: return error;
56: }
57:
58: /**
59: * Returns the nested Error
60: */
61: public Throwable getCause() {
62: return getTargetError();
63: }
64:
65: public void printStackTrace() {
66: if (error == null) {
67: super .printStackTrace();
68: } else {
69: synchronized (System.err) {
70: System.err.println(this );
71: error.printStackTrace();
72: }
73: }
74: }
75:
76: public void printStackTrace(PrintStream s) {
77: if (error == null) {
78: super .printStackTrace(s);
79: } else {
80: synchronized (s) {
81: s.println(this );
82: error.printStackTrace(s);
83: }
84: }
85: }
86:
87: public void printStackTrace(PrintWriter w) {
88: if (error == null) {
89: super.printStackTrace(w);
90: } else {
91: synchronized (w) {
92: w.println(this);
93: error.printStackTrace(w);
94: }
95: }
96: }
97: }
|