001/** 002The contents of this file are subject to the Mozilla Public License Version 1.1 003(the "License"); you may not use this file except in compliance with the License. 004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005Software distributed under the License is distributed on an "AS IS" basis, 006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007specific language governing rights and limitations under the License. 008 009The Original Code is "HL7Exception.java". Description: 010"Represents an exception encountered while processing 011 an HL7 message" 012 013The Initial Developer of the Original Code is University Health Network. Copyright (C) 0142001. All Rights Reserved. 015 016Contributor(s): ______________________________________. 017 018Alternatively, the contents of this file may be used under the terms of the 019GNU General Public License (the "GPL"), in which case the provisions of the GPL are 020applicable instead of those above. If you wish to allow use of your version of this 021file only under the terms of the GPL and not to allow others to use your version 022of this file under the MPL, indicate your decision by deleting the provisions above 023and replace them with the notice and other provisions required by the GPL License. 024If you do not delete the provisions above, a recipient may use your version of 025this file under either the MPL or the GPL. 026 027 */ 028 029package ca.uhn.hl7v2; 030 031 032/** 033 * Represents an exception encountered while processing an HL7 message. 034 * 035 * @author Bryan Tripp (bryan_tripp@sourceforge.net) 036 */ 037@SuppressWarnings("serial") 038public class HL7Exception extends AbstractHL7Exception { 039 040 /** Original mode: Application Accept - Enhanced mode: Application acknowledgment: Accept 041 * 042 * @deprecated use {@link AcknowledgmentCode} 043 */ 044 public static final int ACK_AA = 1; 045 046 /** Original mode: Application Error - Enhanced mode: Application acknowledgment: Error 047 * 048 * @deprecated use {@link AcknowledgmentCode} 049 */ 050 public static final int ACK_AE = 2; 051 052 /** Original mode: Application Reject - Enhanced mode: Application acknowledgment: Reject 053 * 054 * @deprecated use {@link AcknowledgmentCode} 055 */ 056 public static final int ACK_AR = 3; 057 058 /** Enhanced mode: Accept acknowledgment: Commit Accept 059 * 060 * @deprecated use {@link AcknowledgmentCode} 061 */ 062 public static final int ACK_CA = 4; 063 064 /** Enhanced mode: Accept acknowledgment: Commit Error 065 * 066 * @deprecated use {@link AcknowledgmentCode} 067 */ 068 public static final int ACK_CE = 5; 069 070 /** Enhanced mode: Accept acknowledgment: Commit Reject 071 * 072 * @deprecated use {@link AcknowledgmentCode} 073 */ 074 public static final int ACK_CR = 6; 075 076 /** 077 * @deprecated use {@link ErrorCode} 078 */ 079 public static final int MESSAGE_ACCEPTED = 0; 080 /** 081 * @deprecated use {@link ErrorCode} 082 */ 083 public static final int SEGMENT_SEQUENCE_ERROR = 100; 084 /** 085 * @deprecated use {@link ErrorCode} 086 */ 087 public static final int REQUIRED_FIELD_MISSING = 101; 088 /** 089 * @deprecated use {@link ErrorCode} 090 */ 091 public static final int DATA_TYPE_ERROR = 102; 092 /** 093 * @deprecated use {@link ErrorCode} 094 */ 095 public static final int TABLE_VALUE_NOT_FOUND = 103; 096 /** 097 * @deprecated use {@link ErrorCode} 098 */ 099 public static final int UNSUPPORTED_MESSAGE_TYPE = 200; 100 /** 101 * @deprecated use {@link ErrorCode} 102 */ 103 public static final int UNSUPPORTED_EVENT_CODE = 201; 104 /** 105 * @deprecated use {@link ErrorCode} 106 */ 107 public static final int UNSUPPORTED_PROCESSING_ID = 202; 108 /** 109 * @deprecated use {@link ErrorCode} 110 */ 111 public static final int UNSUPPORTED_VERSION_ID = 203; 112 /** 113 * @deprecated use {@link ErrorCode} 114 */ 115 public static final int UNKNOWN_KEY_IDENTIFIER = 204; 116 /** 117 * @deprecated use {@link ErrorCode} 118 */ 119 public static final int DUPLICATE_KEY_IDENTIFIER = 205; 120 /** 121 * @deprecated use {@link ErrorCode} 122 */ 123 public static final int APPLICATION_RECORD_LOCKED = 206; 124 /** 125 * @deprecated use {@link ErrorCode} 126 */ 127 public static final int APPLICATION_INTERNAL_ERROR = 207; 128 129 private Object detail; 130 131 132 /** 133 * Creates an HL7Exception. 134 * 135 * @param errorCondition a code describing the the error condition, from HL7 table 0357 (see 136 * section 2.16.8 of standard v 2.4) - ErrorCode defines these codes 137 * that can be used here (e.g. ErrorCode.UNSUPPORTED_MESSAGE_TYPE.getCode()) 138 * 139 * @param cause The exception that caused this exception to be thrown. 140 * @deprecated use HL7Exception(String, ErrorCode, Throwable) 141 */ 142 public HL7Exception(String message, int errorCondition, Throwable cause) { 143 super(message, cause); 144 setErrorCode(errorCondition); 145 } 146 147 /** 148 * Creates an HL7Exception. 149 * @param message error message 150 * @param error a code describing the the error condition, from HL7 table 0357 (see 151 * section 2.16.8 of standard v 2.4) 152 * 153 * @param cause The exception that caused this exception to be thrown. 154 */ 155 public HL7Exception(String message, ErrorCode error, Throwable cause) { 156 super(message, cause); 157 setError(error); 158 } 159 160 /** 161 * Creates an HL7Exception. 162 * 163 * @param errorCondition a code describing the the error condition, from HL7 table 0357 (see 164 * section 2.16.8 of standard v 2.4) - ErrorCode defines these codes 165 * that can be used here (e.g. ErrorCode.UNSUPPORTED_MESSAGE_TYPE.getCode()) 166 * @deprecated use HL7Exception(String, ErrorCode) 167 */ 168 public HL7Exception(String message, int errorCondition) { 169 super(message); 170 setErrorCode(errorCondition); 171 } 172 173 /** 174 * Creates an HL7Exception. 175 * 176 * @param message error message 177 * @param error a code describing the the error condition, from HL7 table 0357 (see 178 * section 2.16.8 of standard v 2.4). 179 */ 180 public HL7Exception(String message, ErrorCode error) { 181 super(message); 182 setError(error); 183 } 184 185 /** 186 * Creates an HL7Exception with the code APPLICATION_INTERNAL_ERROR 187 * 188 * @param message error message 189 * @param cause The excption that caused this exception tobe thrown. 190 */ 191 public HL7Exception(String message, Throwable cause) { 192 super(message, cause); 193 } 194 195 /** 196 * Creates an HL7Exception with the code APPLICATION_INTERNAL_ERROR 197 * 198 * @param cause The excption that caused this exception tobe thrown. 199 */ 200 public HL7Exception(Throwable cause) { 201 super(cause); 202 } 203 204 /** 205 * Creates an HL7Exception with the code APPLICATION_INTERNAL_ERROR 206 * 207 * @param message error message 208 */ 209 public HL7Exception(String message) { 210 super(message); 211 } 212 213 public Object getDetail() { 214 return detail; 215 } 216 217 /** 218 * @param detail context details for this exception instance 219 */ 220 public void setDetail(Object detail) { 221 this.detail = detail; 222 } 223 224 225 226}