01: /**************************************************************************************
02: * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package org.codehaus.aspectwerkz.aspect.management;
08:
09: import java.io.PrintStream;
10: import java.io.PrintWriter;
11:
12: /**
13: * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
14: */
15: public class NoAspectBoundException extends RuntimeException {
16:
17: private String m_message;
18: private Throwable m_throwable;
19:
20: public NoAspectBoundException(String message, String aspectName) {
21: m_message = message + " - " + aspectName;
22: }
23:
24: public NoAspectBoundException(Throwable t, String aspectName) {
25: m_throwable = t;
26: m_message = t.getMessage();
27: }
28:
29: public String getMessage() {
30: StringBuffer sb = new StringBuffer("NoAspectBound: ");
31: sb.append(m_message);
32: return sb.toString();
33: }
34:
35: /**
36: * Returns the original exception.
37: *
38: * @return the cause
39: */
40: public Throwable getCause() {
41: if (m_throwable != null) {
42: return m_throwable;
43: } else {
44: return super .getCause();
45: }
46: }
47:
48: /**
49: * Prints the wrapped exception A its backtrace to the standard error stream.
50: */
51: public void printStackTrace() {
52: if (m_throwable != null) {
53: m_throwable.printStackTrace();
54: } else {
55: super .printStackTrace();
56: }
57: }
58:
59: /**
60: * Prints the wrapped excpetion A its backtrace to the specified print stream.
61: *
62: * @param s the print stream
63: */
64: public void printStackTrace(final PrintStream s) {
65: if (m_throwable != null) {
66: m_throwable.printStackTrace(s);
67: } else {
68: super .printStackTrace(s);
69: }
70: }
71:
72: /**
73: * Prints the wrapped exception A its backtrace to the specified print writer.
74: *
75: * @param s the print writer
76: */
77: public void printStackTrace(final PrintWriter s) {
78: if (m_throwable != null) {
79: m_throwable.printStackTrace(s);
80: } else {
81: super.printStackTrace(s);
82: }
83: }
84:
85: }
|