001 package calhoun.util;
002
003
004 /** Exception type for general errors. It is unchecked to simplify error handling in the rest of our java code.
005 * It should be used for unrecoverable errors that are probably not due to a system configuration. Users should
006 * be expected to find a developer when one of these occurs. In general these will be bugs in the code or corner
007 * cases you have not implemented. If there is a whole operation or method that is completely not working, just
008 * throw UnsupportedOperationException.
009 */
010 public final class ErrorException extends RuntimeException{
011
012 private static final long serialVersionUID = -7560596902065799827L;
013
014 public ErrorException(String arg0) {
015 super(arg0);
016 }
017
018 public ErrorException(String arg0, Throwable arg1) {
019 //super(arg0, arg1);
020 super(arg0);
021 if(arg1.getCause() != null)
022 initCause(arg1.getCause());
023 else
024 initCause(arg1);
025 }
026
027 public ErrorException(Throwable arg) {
028 //super(arg0);
029 if(arg.getCause() != null)
030 initCause(arg.getCause());
031 else
032 initCause(arg);
033 }
034
035 @Override
036 public String getMessage() {
037 StringBuffer ret = new StringBuffer();
038 ret.append(super.getMessage());
039 Throwable cause = getCause();
040 if(cause != null) {
041 ret.append(" caused by: ").append(cause.getMessage()).append(" - ").append(cause.toString());
042 /*if(cause.getMessage() == null) {
043 Writer w = new StringWriter();
044 cause.printStackTrace(new PrintWriter(w));
045 ret.append(w);
046 }*/
047 }
048 return ret.toString();
049 }
050 }