MT940 Parser v0.4.1 MT940.Parser
This module contains functions to parse SWIFT’s MT940 messages.
API
The parse
function in this module returns {:ok, result}
in case of success, {:error, reason}
otherwise. It is also
followed by a variant that ends with !
which returns the
result (without the {:ok, result}
tuple) in case of success
or raises an exception in case it fails. For example:
import MT940.Parser
parse(":20:TELEWIZORY S.A.")
#=> {:ok, [[%MT940.Job{content: "TELEWIZORY S.A.", modifier: nil, reference: "TELEWIZORY S.A."}]]}
parse("invalid")
#=> {:error, :badarg}
parse!(":20:TELEWIZORY S.A.")
#=> [[%MT940.Job{content: "TELEWIZORY S.A.", modifier: nil, reference: "TELEWIZORY S.A."}]]
parse!("invalid")
#=> raises ArgumentError
In general, a developer should use the former in case he wants to react if the raw input cannot be parsed. The latter should be used when the developer expects his software to fail in case the raw input cannot be parsed (i.e. it is literally an exception).
Summary
Functions
Returns {:ok, result}
, where result
is a list of SWIFT MT940 messages,
or {:error, reason}
if an error occurs
Returns list of SWIFT MT940 messages or raises
ArgumentError
if an error occurs
Functions
Returns {:ok, result}
, where result
is a list of SWIFT MT940 messages,
or {:error, reason}
if an error occurs.
Typical error reasons:
:badarg
- the format of the raw input is not MT940