1 2 package com.calipso.reportgenerator.common; 3 4 7 public class CalipsoException extends java.lang.Exception { 8 9 private Throwable originalException; 10 11 15 public CalipsoException(String message) { 16 super(message); 17 } 18 19 22 public CalipsoException(Throwable cause) { 23 registerCause(cause); 24 } 25 26 private void registerCause(Throwable cause) { 27 this.setOriginalException(cause); 28 } 29 30 31 37 public CalipsoException(String message, Throwable cause) { 38 super(message); 39 registerCause(cause); 40 } 41 42 46 public Throwable 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 60 public Throwable getCause(){ 61 return originalException; 62 } 63 64 68 public void setOriginalException(Throwable originalException){ 69 this.originalException = originalException; 70 } 71 72 75 public void printStackTrace() { 76 super.printStackTrace(); 77 if (this.getCause() != null) { 78 this.getCause().printStackTrace(); 79 } 80 } 81 82 } 83 | Popular Tags |