Class: MllpAckError
Error a message handler throws to control the negative acknowledgement the server
returns. Throwing any error from a commit-gated handler yields AE by default;
throw an MllpAckError to choose AR (application reject) instead.
The message is never copied into the ACK bytes or any emitted event, it may
carry PHI. Only the static, non-PHI ackCode influences the wire response.
Example
import { createServer, MllpAckError } from '@cosyte/mllp';
createServer({
autoAck: 'AA',
onMessage: async (payload) => {
if (!isAcceptable(payload)) {
// sender should NOT resend unchanged -> AR
throw new MllpAckError('unsupported message type', { ackCode: 'AR' });
}
await db.commit(payload); // throw here -> AE (resend may succeed)
},
});
Extends
Error
Constructors
Constructor
new MllpAckError(
message,opts?):MllpAckError
Parameters
message
string
Diagnostic text for the thrower. Never placed on the wire (may carry PHI).
opts?
ackCode?
Negative code to return. Default 'AE'.
cause?
unknown
Underlying error, preserved on .cause.
Returns
MllpAckError
Overrides
Error.constructor
Properties
ackCode
readonlyackCode:NegativeAckCode
The negative acknowledgement code to return (AE or AR).