001 /* 002 @license.text@ 003 */ 004 package biz.hammurapi; 005 006 /** 007 * This exception adds "root cause" throwable class and message to its message 008 * @author Pavel Vlasov 009 * @version $Revision: 1.2 $ 010 */ 011 public class Exception extends java.lang.Exception { 012 013 /** 014 * Comment for <code>serialVersionUID</code> 015 */ 016 private static final long serialVersionUID = 9056009202942745656L; 017 018 public Exception() { 019 super(); 020 } 021 022 public Exception(String message) { 023 super(message); 024 } 025 026 public Exception(String message, Throwable cause) { 027 // TODO Switch to select 1.3 or 1.4 028 super(message+rootCause(cause), cause); 029 } 030 031 public Exception(Throwable cause) { 032 // TODO Switch to select 1.3 or 1.4 033 super(rootCause(cause), cause); 034 } 035 036 static String rootCause(Throwable cause) { 037 while (cause!=null && cause.getCause()!=null && cause!=cause.getCause()) { 038 cause=cause.getCause(); 039 } 040 return cause==null ? "" : "\nRoot cause: "+cause.toString(); 041 } 042 }