1 55 56 package org.apache.bsf; 57 58 67 public class BSFException extends Exception { 68 public static int REASON_INVALID_ARGUMENT = 0; 69 public static int REASON_IO_ERROR = 10; 70 public static int REASON_UNKNOWN_LANGUAGE = 20; 71 public static int REASON_EXECUTION_ERROR = 100; 72 public static int REASON_UNSUPPORTED_FEATURE = 499; 73 public static int REASON_OTHER_ERROR = 500; 74 75 int reason; 76 Throwable targetThrowable; 77 78 public BSFException (int reason, String msg) { 79 super (msg); 80 this.reason = reason; 81 } 82 public BSFException (int reason, String msg, Throwable t) { 83 this (reason, msg); 84 targetThrowable = t; 85 } 86 public BSFException (String msg) { 87 this (REASON_OTHER_ERROR, msg); 88 } 89 public int getReason () { 90 return reason; 91 } 92 public Throwable getTargetException () { 93 return targetThrowable; 94 } 95 public void printStackTrace () { 96 if (targetThrowable != null) { 97 String msg = getMessage (); 98 99 if (msg != null && !msg.equals (targetThrowable.getMessage ())) { 100 System.err.print (msg + ": "); 101 } 102 103 targetThrowable.printStackTrace (); 104 } else { 105 super.printStackTrace (); 106 } 107 } 108 } 109 | Popular Tags |