-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Currently, MLLP.Ack returns the follow when verifying per the follow spec :
@type ack_verification_result ::
{:ok, atom(), MLLP.Ack.t()}
| {:error, atom(), MLLP.Ack.t()}
| {:error, :bad_ack_code, String.t()}
| {:error, :bad_message_control_id, String.t()}
| {:error, :invalid_message, String.t()}
| {:error, :invalid_ack_message, String.t()}
I think what would be more ergonomic is return a two element tuple. Either an ok tuple or an error tuple.
Specifically, I think it would be advantageous to always return {:ok, %Ack{}} or {:error, Ack{}} and simply put the error code (that's currently the second element) in the Ack struct and always put the ack message in the Ack tuple (currently can be the third element in a return).
So in the case of say an invalid ack message {:error, %Ack{error: :invalid_ack_message}}
Doing so would allow us in MLLP.Client to always return a two element tuple for the sake of consistency, then it's up to the caller to match on the error code in the struct, etc. if they so choose.
Edit:
Note if we want to send a better signal for matching purposes, an idea might be to have two or three structs, Ack, Nack, and AckError, something along those lines.