1 16 package scriptella.util; 17 18 import scriptella.core.ExceptionInterceptor; 19 import scriptella.core.SystemException; 20 import scriptella.execution.EtlExecutorException; 21 22 import java.io.PrintWriter ; 23 import java.io.StringWriter ; 24 25 31 public class BugReport { 32 private Throwable throwable; 33 34 39 public BugReport(Throwable throwable) { 40 this.throwable = throwable; 41 } 42 43 47 public static boolean isPossibleBug(Throwable throwable) { 48 if (throwable instanceof ExceptionInterceptor.ExecutionException) { 49 if (throwable.getCause() != null) { 51 return isPossibleBug(throwable.getCause()); 52 } else { 53 return true; } 55 } else if (throwable instanceof EtlExecutorException) { 56 if (throwable.getCause() != null) { 57 return isPossibleBug(throwable.getCause()); 58 } else { 59 return true; } 61 } 62 return !(throwable instanceof SystemException); 63 } 64 65 68 public String toString() { 69 StringWriter rep = new StringWriter (); 71 PrintWriter pw = new PrintWriter (rep); 72 pw.println("Scriptella bug report. Submit to issue tracker."); 73 Package p = BugReport.class.getPackage(); 74 String version = p != null && p.getImplementationVersion() != null ? p.getImplementationVersion() : "Unknown"; 75 pw.println("Scriptella version: " + version); 76 pw.println("Exception: "); 77 throwable.printStackTrace(pw); 78 pw.println("Environment: "); 79 pw.println(System.getenv()); 80 pw.println("System properties: "); 81 pw.println(System.getProperties()); 82 pw.println("-----------------------------------------------------------------"); 83 return rep.toString(); 85 86 } 87 88 89 } 90 | Popular Tags |