atto/error

Values

pub fn pretty(
  err: atto.ParseError(e, t),
  in: atto.ParserInput(t, s),
  color color: Bool,
) -> String

Prettyprint a parse error for display. The in parameter must be the original input to the parser. If color is True, the error message will contain ANSI color codes.

Examples

let in = gleam.text.new("7")
let assert Error(e) =
  gleam.choice([gleam.token("5"), gleam.token("6")])
  |> gleam.run(in, Nil)
gleam.pretty(e, in, False)
// -> Parse error: Expected one of "5", "6", got 7
Search Document