Skip to main content
Version: v0.0.3

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?

NegativeAckCode

Negative code to return. Default 'AE'.

cause?

unknown

Underlying error, preserved on .cause.

Returns

MllpAckError

Overrides

Error.constructor

Properties

ackCode

readonly ackCode: NegativeAckCode

The negative acknowledgement code to return (AE or AR).