Coverage Report - ca.uhn.hl7v2.HL7Exception
 
Classes in this File Line Coverage Branch Coverage Complexity
HL7Exception
52%
11/21
N/A
1
 
 1  
 /**
 2  
 The contents of this file are subject to the Mozilla Public License Version 1.1 
 3  
 (the "License"); you may not use this file except in compliance with the License. 
 4  
 You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
 5  
 Software distributed under the License is distributed on an "AS IS" basis, 
 6  
 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
 7  
 specific language governing rights and limitations under the License. 
 8  
 
 9  
 The Original Code is "HL7Exception.java".  Description: 
 10  
 "Represents an exception encountered while processing 
 11  
   an HL7 message" 
 12  
 
 13  
 The Initial Developer of the Original Code is University Health Network. Copyright (C) 
 14  
 2001.  All Rights Reserved. 
 15  
 
 16  
 Contributor(s): ______________________________________. 
 17  
 
 18  
 Alternatively, the contents of this file may be used under the terms of the 
 19  
 GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
 20  
 applicable instead of those above.  If you wish to allow use of your version of this 
 21  
 file only under the terms of the GPL and not to allow others to use your version 
 22  
 of this file under the MPL, indicate your decision by deleting  the provisions above 
 23  
 and replace  them with the notice and other provisions required by the GPL License.  
 24  
 If you do not delete the provisions above, a recipient may use your version of 
 25  
 this file under either the MPL or the GPL. 
 26  
 
 27  
  */
 28  
 
 29  
 package ca.uhn.hl7v2;
 30  
 
 31  
 
 32  
 /**
 33  
  * Represents an exception encountered while processing an HL7 message.
 34  
  * 
 35  
  * @author Bryan Tripp (bryan_tripp@sourceforge.net)
 36  
  */
 37  
 @SuppressWarnings("serial")
 38  
 public class HL7Exception extends AbstractHL7Exception {
 39  
 
 40  
         /** Original mode: Application Accept - Enhanced mode: Application acknowledgment: Accept
 41  
      *
 42  
      * @deprecated use {@link AcknowledgmentCode}
 43  
      */
 44  
         public static final int ACK_AA = 1;
 45  
 
 46  
         /** Original mode: Application Error - Enhanced mode: Application acknowledgment: Error
 47  
     *
 48  
     * @deprecated use {@link AcknowledgmentCode}
 49  
     */
 50  
     public static final int ACK_AE = 2;
 51  
 
 52  
         /** Original mode: Application Reject - Enhanced mode: Application acknowledgment: Reject 
 53  
      *
 54  
      * @deprecated use {@link AcknowledgmentCode}
 55  
      */        
 56  
     public static final int ACK_AR = 3;
 57  
 
 58  
         /** Enhanced mode: Accept acknowledgment: Commit Accept 
 59  
      *
 60  
      * @deprecated use {@link AcknowledgmentCode}
 61  
      */        
 62  
     public static final int ACK_CA = 4;
 63  
 
 64  
         /** Enhanced mode: Accept acknowledgment: Commit Error 
 65  
      *
 66  
      * @deprecated use {@link AcknowledgmentCode}
 67  
      */        
 68  
     public static final int ACK_CE = 5;
 69  
 
 70  
         /** Enhanced mode: Accept acknowledgment: Commit Reject 
 71  
      *
 72  
      * @deprecated use {@link AcknowledgmentCode}
 73  
      */        
 74  
     public static final int ACK_CR = 6;
 75  
 
 76  
         /**
 77  
          * @deprecated use {@link ErrorCode}
 78  
          */
 79  
         public static final int MESSAGE_ACCEPTED = 0;
 80  
         /**
 81  
          * @deprecated use {@link ErrorCode}
 82  
          */        
 83  
         public static final int SEGMENT_SEQUENCE_ERROR = 100;
 84  
         /**
 85  
          * @deprecated use {@link ErrorCode}
 86  
          */        
 87  
         public static final int REQUIRED_FIELD_MISSING = 101;
 88  
         /**
 89  
          * @deprecated use {@link ErrorCode}
 90  
          */        
 91  
         public static final int DATA_TYPE_ERROR = 102;
 92  
         /**
 93  
          * @deprecated use {@link ErrorCode}
 94  
          */        
 95  
         public static final int TABLE_VALUE_NOT_FOUND = 103;
 96  
         /**
 97  
          * @deprecated use {@link ErrorCode}
 98  
          */
 99  
         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  0
                 super(message, cause);
 144  0
                 setErrorCode(errorCondition);
 145  0
         }
 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  0
                 super(message, cause);
 157  0
                 setError(error);
 158  0
         }
 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  0
                 super(message);
 170  0
                 setErrorCode(errorCondition);
 171  0
         }
 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  140
                 super(message);
 182  140
                 setError(error);
 183  140
         }        
 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  175
                 super(message, cause);
 193  175
         }
 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  780
                 super(cause);
 202  780
         }
 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  1605
                 super(message);
 211  1605
         }
 212  
 
 213  
     public Object getDetail() {
 214  0
         return detail;
 215  
     }
 216  
 
 217  
     /**
 218  
      * @param detail context details for this exception instance
 219  
      */
 220  
     public void setDetail(Object detail) {
 221  10
         this.detail = detail;
 222  10
     }
 223  
 
 224  
         
 225  
 
 226  
 }