1 28 package net.sf.jasperreports.engine; 29 30 import java.io.PrintStream ; 31 import java.io.PrintWriter ; 32 33 34 38 public class JRRuntimeException extends RuntimeException 39 { 40 41 44 private static boolean isJre14orLater = true; 45 46 static 47 { 48 isJre14orLater = true; 49 try 50 { 51 Exception .class.getMethod("getCause", (Class [])null); 52 } 53 catch (NoSuchMethodException e) 54 { 55 isJre14orLater = false; 56 } 57 } 58 59 62 private Throwable nestedThrowable = null; 63 64 65 68 public JRRuntimeException(String message) 69 { 70 super(message); 71 } 72 73 74 77 public JRRuntimeException(Throwable t) 78 { 79 this(t.toString(), t); 80 } 81 82 83 86 public JRRuntimeException(String message, Throwable t) 87 { 88 super(message); 89 90 nestedThrowable = t; 91 } 92 93 94 97 public Throwable getCause() 98 { 99 return nestedThrowable; 100 } 101 102 103 106 public void printStackTrace() 107 { 108 if (!isJre14orLater && nestedThrowable != null) 109 { 110 nestedThrowable.printStackTrace(); 111 System.err.println("\nNested by:"); 112 } 113 114 super.printStackTrace(); 115 } 116 117 118 121 public void printStackTrace(PrintStream s) 122 { 123 if (!isJre14orLater && nestedThrowable != null) 124 { 125 nestedThrowable.printStackTrace(s); 126 s.println("\nNested by:"); 127 } 128 129 super.printStackTrace(s); 130 } 131 132 133 136 public void printStackTrace(PrintWriter s) 137 { 138 if (!isJre14orLater && nestedThrowable != null) 139 { 140 nestedThrowable.printStackTrace(s); 141 s.println("\nNested by:"); 142 } 143 144 super.printStackTrace(s); 145 } 146 147 148 } 149 | Popular Tags |