Ergo.Meta.failed
You're seeing just the function
failed
, go back to Ergo.Meta module for more information.
Link to this function
failed(parser, fail_fn, opts \\ [])
The failed
parser is a combinator that invokes a parser and if the parser fails
runs the given function on the resulting context. This can be used to output additional
debugging information where failure was unexpected.
Examples
iex> alias Ergo.Parser
iex> import Ergo.Meta
iex> failing_parser = Parser.combinator(:err, "err_parser", fn ctx -> %{ctx | status: {:error, :unfathomable_error}} end)
iex> parser = failed(failing_parser, fn _pre_ctx, _post_ctx, _parser -> send(self(), :failed) end)
iex> Ergo.parse(parser, "")
iex> assert_received :failed