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