1 /* 2 * Copyright 2004 Jonathan M. Lehr 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 * governing permissions and limitations under the License. 12 * 13 * MODIFIED BY THE KUALI FOUNDATION 14 */ 15 // begin Kuali Foundation modification 16 package org.kuali.rice.kns.web.format; 17 // end Kuali Foundation modification 18 19 import org.kuali.rice.kns.util.RiceKeyConstants; 20 21 /** 22 * begin Kuali Foundation modification 23 * javadoc changed 24 * This class is used to format Exception messages. 25 * end Kuali Foundation modification 26 */ 27 public class FormatException extends RuntimeException { 28 private static final long serialVersionUID = 6679793710457672426L; 29 30 // begin Kuali Foundation modification 31 // removed member variables: cause, formatter 32 // added the following 33 private String formatProperty; 34 private Object formatValue; 35 private final String errorKey; 36 private final String[] errorArgs; 37 // end Kuali Foundation modification 38 39 // begin Kuali Foundation modification 40 // removed public FormatException(Formatter formatter) 41 // end Kuali Foundation modification 42 43 public FormatException(String message) { 44 // begin Kuali Foundation modification 45 // orig code: this(message, null); 46 this(message, RiceKeyConstants.ERROR_CUSTOM, message); 47 // end Kuali Foundation modification 48 } 49 50 public FormatException(String message, Throwable cause) { 51 // begin Kuali Foundation modification 52 /* orig code: 53 super(message); 54 this.cause = cause; 55 */ 56 this(message, RiceKeyConstants.ERROR_CUSTOM, message, cause); 57 // end Kuali Foundation modification 58 } 59 60 // begin Kuali Foundation modification 61 // removed getCause(), getFormatter, printStackTrace, setCause(Throwable), setFormatter 62 // added thse methods 63 public FormatException(String message, String errorKey, String errorArg) { 64 super(message + ", " + errorKey + "[" + errorArg + "]"); 65 this.errorKey = errorKey; 66 this.errorArgs = new String[] { errorArg }; 67 } 68 69 public FormatException(String message, String errorKey, String errorArg, Throwable cause) { 70 this(message, errorKey, errorArg); 71 initCause(cause); 72 } 73 74 /** 75 * @return Returns the formatProperty. 76 */ 77 public String getFormatProperty() { 78 return formatProperty; 79 } 80 81 /** 82 * @param formatProperty The formatProperty to set. 83 */ 84 public void setFormatProperty(String formatProperty) { 85 this.formatProperty = formatProperty; 86 } 87 88 /** 89 * @return Returns the formatValue. 90 */ 91 public Object getFormatValue() { 92 return formatValue; 93 } 94 95 /** 96 * @param formatValue The formatValue to set. 97 */ 98 public void setFormatValue(Object formatValue) { 99 this.formatValue = formatValue; 100 } 101 102 /** 103 * @return the error key for use in the global error map. 104 */ 105 public String getErrorKey() { 106 return errorKey; 107 } 108 109 /** 110 * @return the array of arguments for the keyed error message. 111 */ 112 public String[] getErrorArgs() { 113 return errorArgs; 114 } 115 // end Kuali Foundation modification 116 }