CEL.Error exception (CEL v0.2.0)

Copy Markdown View Source

Unified error raised by CEL evaluation, including protovalidate cel rules.

:phase discriminates :parse, :check, or :eval. Callers rescue CEL.Error once and inspect :phase to discriminate if needed.

Parse and check errors say where in the source the error was found: for a check error, the position of the expression it is about, as CEL.Checked.position/2 gives it.

  • :offset — the offset in code points.
  • :line and :column — the 1-based line and column, in code points.
  • :location — the source's location, as given to CEL.parse/2.

Summary

Functions

Builds the error. :message is always a string: a non-string reason from the runtime is described in words and kept as details.reason.

Types

phase()

@type phase() :: :parse | :check | :eval

t()

@type t() :: %CEL.Error{
  __exception__: term(),
  column: pos_integer() | nil,
  details: map() | nil,
  expr_id: integer() | nil,
  line: pos_integer() | nil,
  location: String.t() | nil,
  message: String.t(),
  offset: non_neg_integer() | nil,
  phase: phase()
}

Functions

exception(msg)

Builds the error. :message is always a string: a non-string reason from the runtime is described in words and kept as details.reason.