1 18 19 package org.apache.roller; 20 21 import java.io.PrintStream ; 22 import java.io.PrintWriter ; 23 24 25 28 public class RollerException extends Exception { 29 30 private Throwable mRootCause = null; 31 32 33 36 public RollerException() { 37 super(); 38 } 39 40 41 45 public RollerException(String s) { 46 super(s); 47 } 48 49 50 55 public RollerException(String s, Throwable t) { 56 super(s); 57 mRootCause = t; 58 } 59 60 61 65 public RollerException(Throwable t) { 66 mRootCause = t; 67 } 68 69 70 74 public Throwable getRootCause() { 75 return mRootCause; 76 } 77 78 79 83 public String getRootCauseMessage() { 84 String rcmessage = null; 85 if (getRootCause()!=null) { 86 if (getRootCause().getCause()!=null) { 87 rcmessage = getRootCause().getCause().getMessage(); 88 } 89 rcmessage = (rcmessage == null) ? getRootCause().getMessage() : rcmessage; 90 rcmessage = (rcmessage == null) ? super.getMessage() : rcmessage; 91 rcmessage = (rcmessage == null) ? "NONE" : rcmessage; 92 } 93 return rcmessage; 94 } 95 96 97 101 public void printStackTrace() { 102 super.printStackTrace(); 103 if (mRootCause != null) { 104 System.out.println("--- ROOT CAUSE ---"); 105 mRootCause.printStackTrace(); 106 } 107 } 108 109 110 114 public void printStackTrace(PrintStream s) { 115 super.printStackTrace(s); 116 if (mRootCause != null) { 117 s.println("--- ROOT CAUSE ---"); 118 mRootCause.printStackTrace(s); 119 } 120 } 121 122 123 127 public void printStackTrace(PrintWriter s) { 128 super.printStackTrace(s); 129 if (null != mRootCause) { 130 s.println("--- ROOT CAUSE ---"); 131 mRootCause.printStackTrace(s); 132 } 133 } 134 135 } 136 | Popular Tags |