1 2 package org.roller; 3 4 import java.io.PrintStream ; 5 import java.io.PrintWriter ; 6 7 10 public class RollerException extends Exception 11 { 12 private Throwable mRootCause = null; 13 14 19 public RollerException(String s,Throwable t) 20 { 21 super(s); 22 mRootCause = t; 23 } 24 28 public RollerException(Throwable t) 29 { 30 mRootCause = t; 31 } 32 36 public RollerException(String s) 37 { 38 super(s); 39 } 40 43 public RollerException() 44 { 45 super(); 46 } 47 51 public Throwable getRootCause() 52 { 53 return mRootCause; 54 } 55 56 60 public void printStackTrace() 61 { 62 super.printStackTrace(); 63 if (mRootCause != null) 64 { 65 System.out.println("--- ROOT CAUSE ---"); 66 mRootCause.printStackTrace(); 67 } 68 } 69 70 74 public void printStackTrace(PrintStream s) 75 { 76 super.printStackTrace(s); 77 if (mRootCause != null) 78 { 79 s.println("--- ROOT CAUSE ---"); 80 mRootCause.printStackTrace(s); 81 } 82 } 83 84 88 public void printStackTrace(PrintWriter s) 89 { 90 super.printStackTrace(s); 91 if (null != mRootCause) 92 { 93 s.println("--- ROOT CAUSE ---"); 94 mRootCause.printStackTrace(s); 95 } 96 } 97 98 102 public String getRootCauseMessage() 103 { 104 String rcmessage = null; 105 if (getRootCause()!=null) 106 { 107 if (getRootCause().getCause()!=null) 108 { 109 rcmessage = getRootCause().getCause().getMessage(); 110 } 111 rcmessage = (rcmessage == null) ? getRootCause().getMessage() : rcmessage; 112 rcmessage = (rcmessage == null) ? super.getMessage() : rcmessage; 113 rcmessage = (rcmessage == null) ? "NONE" : rcmessage; 114 } 115 return rcmessage; 116 } 117 } 118 119 | Popular Tags |