1 21 package com.jaspersoft.jasperserver.api; 22 23 import java.io.PrintWriter ; 24 import java.io.StringWriter ; 25 26 30 public class JSExceptionWrapper extends JSException { 31 32 private final String stackTrace; 33 34 private final Exception originalException; 35 36 public JSExceptionWrapper(Exception e) { 37 super(e.toString()); 38 39 originalException = e; 40 stackTrace = readStackTrace(e); 41 } 42 43 private String readStackTrace(Exception e) { 44 StringWriter sw = new StringWriter (); 45 e.printStackTrace(new PrintWriter (sw)); 46 return sw.toString(); 47 } 48 49 public void printStackTrace() { 50 printStackTrace(System.err); 51 } 52 53 public void printStackTrace(java.io.PrintStream s) { 54 synchronized (s) { 55 s.print(getClass().getName() + ": "); 56 s.print(stackTrace); 57 } 58 } 59 60 public void printStackTrace(java.io.PrintWriter s) { 61 synchronized (s) { 62 s.print(getClass().getName() + ": "); 63 s.print(stackTrace); 64 } 65 } 66 67 public void rethrow() throws Exception { 68 throw originalException; 69 } 70 } 71 | Popular Tags |