1 /***************************************************************************************
2 * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
8 package org.codehaus.aspectwerkz.exception;
9
10 import java.io.PrintStream;
11 import java.io.PrintWriter;
12
13 /***
14 * Wrappes the original throwable in a RuntimeException.
15 *
16 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
17 */
18 public class WrappedRuntimeException extends RuntimeException {
19 /***
20 * The original throwable instance.
21 */
22 private final Throwable m_throwable;
23
24 /***
25 * Creates a new WrappedRuntimeException.
26 *
27 * @param throwable the non-RuntimeException to be wrapped.
28 */
29 public WrappedRuntimeException(final Throwable throwable) {
30 m_throwable = throwable;
31 }
32
33 /***
34 * Returns the error message string of the wrapped exception.
35 *
36 * @return the error message string of the wrapped exception
37 */
38 public String getMessage() {
39 return m_throwable.getMessage();
40 }
41
42 /***
43 * Returns the localized description of the wrapped exception in order to produce a locale-specific message.
44 *
45 * @return the localized description of the wrapped exception.
46 */
47 public String getLocalizedMessage() {
48 return m_throwable.getLocalizedMessage();
49 }
50
51 /***
52 * Returns the original exception.
53 *
54 * @return the cause
55 */
56 public Throwable getCause() {
57 return m_throwable;
58 }
59
60 /***
61 * Returns a short description of the wrapped exception.
62 *
63 * @return a string representation of the wrapped exception.
64 */
65 public String toString() {
66 return m_throwable.toString();
67 }
68
69
70
71 /***
72 * Prints the wrapped exception A its backtrace to the standard error stream.
73 */
74 public void printStackTrace() {
75 m_throwable.printStackTrace();
76 }
77
78 /***
79 * Prints the wrapped excpetion A its backtrace to the specified print stream.
80 *
81 * @param s the print stream
82 */
83 public void printStackTrace(final PrintStream s) {
84 m_throwable.printStackTrace(s);
85 }
86
87 /***
88 * Prints the wrapped exception A its backtrace to the specified print writer.
89 *
90 * @param s the print writer
91 */
92 public void printStackTrace(final PrintWriter s) {
93 m_throwable.printStackTrace(s);
94 }
95
96
97 }