1 package com.protomatter.util; 2 3 52 53 import java.io.*; 54 55 58 public class ChainedRuntimeException 59 extends RuntimeException 60 { 61 private Throwable nextException = null; 62 63 public ChainedRuntimeException(String message) 64 { 65 super(message); 66 } 67 68 public ChainedRuntimeException(String message, Throwable nextException) 69 { 70 this(message); 71 this.nextException = nextException; 72 } 73 74 public Throwable getNextException() 75 { 76 return this.nextException; 77 } 78 79 public void printStackTrace() 80 { 81 super.printStackTrace(); 82 if (nextException != null) 83 { 84 System.err.print(UtilResources.getResourceString(MessageConstants.CAUSED_BY) + " "); 85 nextException.printStackTrace(); 86 } 87 } 88 89 public void printStackTrace(java.io.PrintStream ps) 90 { 91 super.printStackTrace(ps); 92 if (nextException != null) 93 { 94 ps.print(UtilResources.getResourceString(MessageConstants.CAUSED_BY) + " "); 95 nextException.printStackTrace(ps); 96 } 97 } 98 99 public void printStackTrace(java.io.PrintWriter pw) 100 { 101 super.printStackTrace(pw); 102 if (nextException != null) 103 { 104 pw.print(UtilResources.getResourceString(MessageConstants.CAUSED_BY) + " "); 105 nextException.printStackTrace(pw); 106 } 107 } 108 } 109 | Popular Tags |