01: package com.calipso.reportgenerator.common;
02:
03: /**
04: * Calipso exception
05: */
06: public class CalipsoException extends java.lang.Exception {
07:
08: private Throwable originalException;
09:
10: /**
11: * Constructor
12: * @param descripcion de la excepcion
13: */
14: public CalipsoException(String message) {
15: super (message);
16: }
17:
18: /**
19: * Constructor
20: */
21: public CalipsoException(Throwable cause) {
22: registerCause(cause);
23: }
24:
25: private void registerCause(Throwable cause) {
26: this .setOriginalException(cause);
27: }
28:
29: /**
30: * Constructor
31: *
32: * @param descripcion del mensage
33: * @param causa
34: */
35: public CalipsoException(String message, Throwable cause) {
36: super (message);
37: registerCause(cause);
38: }
39:
40: /**
41: * Devuelve la excepción originaria que ha causado esta CalipsoException.
42:
43: */
44: public Throwable getOriginalException() {
45: if (this .getCause() == null) {
46: return this ;
47: } else if (this .originalException instanceof CalipsoException) {
48: return ((CalipsoException) this .originalException)
49: .getOriginalException();
50: } else {
51: return this .originalException;
52: }
53: }
54:
55: /**
56: * Retorna la primera excepcion
57: */
58: public Throwable getCause() {
59: return originalException;
60: }
61:
62: /**
63: * Sets the first exception (if any) from the stack. Normally
64: * <code>CalipsoException</code> wraps other low level exceptions.
65: */
66: public void setOriginalException(Throwable originalException) {
67: this .originalException = originalException;
68: }
69:
70: /**
71: * @see java.lang.Throwable#printStackTrace()
72: */
73: public void printStackTrace() {
74: super.printStackTrace();
75: if (this.getCause() != null) {
76: this.getCause().printStackTrace();
77: }
78: }
79:
80: }
|