001package ca.uhn.hl7v2.protocol;
002
003import java.util.Map;
004
005import ca.uhn.hl7v2.HL7Exception;
006
007/**
008 * The Interface ReceivingApplicationExceptionHandler. Allow applications to handle
009 * parsing and handling errors.
010 *
011 * @author Gabriel Landais
012 */
013public interface ReceivingApplicationExceptionHandler {
014
015        /**
016         * Process an exception.
017         * 
018         * @param incomingMessage
019         *            the incoming message. This is the raw message which was
020         *            received from the external system
021         * @param incomingMetadata
022         *            Any metadata that accompanies the incoming message. See {@link ca.uhn.hl7v2.protocol.Transportable#getMetadata()}
023         * @param outgoingMessage
024         *            the outgoing message. The response NAK message generated by
025         *            HAPI.
026         * @param e
027         *            the exception which was received
028         * @return The new outgoing message. This can be set to the value provided
029         *         by HAPI in <code>outgoingMessage</code>, or may be replaced with
030         *         another message. <b>This method may not return <code>null</code></b>.
031         */
032        // ********************************
033        // Note, if you update the JavaDoc here, also update it in the hapi-example
034        // file SendAndReceiveAMessage.java as it's duplicated there!
035        // ********************************
036        public String processException(String incomingMessage, Map<String, Object> incomingMetadata, String outgoingMessage, Exception e) throws HL7Exception;
037
038}