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.aspect.management;
9
10 import java.io.PrintStream;
11 import java.io.PrintWriter;
12
13 /***
14 * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
15 */
16 public class NoAspectBoundException extends RuntimeException {
17
18 private String m_message;
19 private Throwable m_throwable;
20
21 public NoAspectBoundException(String message, String aspectName) {
22 m_message = message + " - " + aspectName;
23 }
24
25 public NoAspectBoundException(Throwable t, String aspectName) {
26 m_throwable = t;
27 m_message = t.getMessage();
28 }
29
30 public String getMessage() {
31 StringBuffer sb = new StringBuffer("NoAspectBound: ");
32 sb.append(m_message);
33 return sb.toString();
34 }
35
36 /***
37 * Returns the original exception.
38 *
39 * @return the cause
40 */
41 public Throwable getCause() {
42 if (m_throwable != null) {
43 return m_throwable;
44 } else {
45 return super.getCause();
46 }
47 }
48
49 /***
50 * Prints the wrapped exception A its backtrace to the standard error stream.
51 */
52 public void printStackTrace() {
53 if (m_throwable != null) {
54 m_throwable.printStackTrace();
55 } else {
56 super.printStackTrace();
57 }
58 }
59
60 /***
61 * Prints the wrapped excpetion A its backtrace to the specified print stream.
62 *
63 * @param s the print stream
64 */
65 public void printStackTrace(final PrintStream s) {
66 if (m_throwable != null) {
67 m_throwable.printStackTrace(s);
68 } else {
69 super.printStackTrace(s);
70 }
71 }
72
73 /***
74 * Prints the wrapped exception A its backtrace to the specified print writer.
75 *
76 * @param s the print writer
77 */
78 public void printStackTrace(final PrintWriter s) {
79 if (m_throwable != null) {
80 m_throwable.printStackTrace(s);
81 } else {
82 super.printStackTrace(s);
83 }
84 }
85
86 }