KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > common > CalipsoException


1
2 package com.calipso.reportgenerator.common;
3
4 /**
5  * Calipso exception
6  */

7 public class CalipsoException extends java.lang.Exception JavaDoc {
8
9     private Throwable JavaDoc originalException;
10
11     /**
12      * Constructor
13      * @param descripcion de la excepcion
14      */

15     public CalipsoException(String JavaDoc message) {
16       super(message);
17     }
18
19     /**
20      * Constructor
21      */

22     public CalipsoException(Throwable JavaDoc cause) {
23       registerCause(cause);
24     }
25
26   private void registerCause(Throwable JavaDoc cause) {
27             this.setOriginalException(cause);
28   }
29
30
31   /**
32    * Constructor
33    *
34    * @param descripcion del mensage
35    * @param causa
36    */

37   public CalipsoException(String JavaDoc message, Throwable JavaDoc cause) {
38       super(message);
39       registerCause(cause);
40   }
41
42     /**
43      * Devuelve la excepción originaria que ha causado esta CalipsoException.
44
45      */

46     public Throwable JavaDoc getOriginalException() {
47         if (this.getCause() == null) {
48             return this;
49         } else if (this.originalException instanceof CalipsoException) {
50             return ((CalipsoException)this.originalException).getOriginalException();
51         } else {
52             return this.originalException;
53         }
54     }
55
56
57     /**
58      * Retorna la primera excepcion
59      */

60     public Throwable JavaDoc getCause(){
61         return originalException;
62     }
63
64     /**
65      * Sets the first exception (if any) from the stack. Normally
66      * <code>CalipsoException</code> wraps other low level exceptions.
67      */

68     public void setOriginalException(Throwable JavaDoc originalException){
69         this.originalException = originalException;
70     }
71
72     /**
73      * @see java.lang.Throwable#printStackTrace()
74      */

75     public void printStackTrace() {
76         super.printStackTrace();
77         if (this.getCause() != null) {
78             this.getCause().printStackTrace();
79         }
80     }
81
82 }
83
Popular Tags