1 package net.firstpartners.nounit.utility; 2 3 26 27 31 public class NoUnitException extends Exception { 32 33 34 private String userErrorMessage; 36 private Exception internalException; 37 38 39 44 public NoUnitException(Exception inException, String userFriendlyMessage) { 45 46 super(inException.toString()); 48 49 internalException = inException; 51 52 userErrorMessage=userFriendlyMessage; 54 55 } 56 57 58 63 public NoUnitException(String inValidValueName , String inValidValue) { 64 super ("Invalid value submitted ("+inValidValue+") under keyname "+inValidValueName); 65 66 userErrorMessage=this.toString(); 68 69 internalException = this; 71 72 } 73 74 80 public NoUnitException(String inValidValueName , String inValidValue ,String reason) { 81 super ("Invalid value submitted ("+inValidValue+") under keyname "+inValidValueName 82 + " reason: "+reason); 83 84 internalException = this; 86 87 userErrorMessage=this.toString(); 89 } 90 91 95 public NoUnitException(String inUserErrorMessage) { 96 super (inUserErrorMessage); 97 98 internalException = this; 100 101 userErrorMessage=inUserErrorMessage; 103 } 104 105 109 public String getUserErrorMessage() { 110 return userErrorMessage; 111 } 112 113 114 119 public String toString(){ 120 121 StringBuffer infoString = new StringBuffer ("Exception:"); 123 infoString.append(super.toString()); 124 infoString.append("\n"); 125 infoString.append("UserMessage:"); 126 infoString.append(getUserErrorMessage()); 127 infoString.append("\n"); 128 129 if ((internalException!=null)&&(!(internalException instanceof NoUnitException))) { 131 infoString.append("Original Exception:"); 132 infoString.append(internalException.toString()); 133 infoString.append("\n"); 134 } 135 136 return infoString.toString(); 137 138 } 139 140 144 public Exception getOriginalException() { 145 146 return this.internalException; 147 148 } 149 150 } | Popular Tags |