# `Predicator.Errors.EvaluationError`
[🔗](https://github.com/riddler/predicator-ex/blob/v9.4.1/lib/predicator/errors/evaluation_error.ex#L1)

Error struct for general evaluation errors in Predicator evaluation.

This error occurs for runtime evaluation problems like division by zero,
function call errors, or insufficient operands.

## Fields

- `message` - Human-readable error description
- `reason` - Structured reason code for the error
- `operation` - The operation that failed (optional)
- `position` - `{line, column}` of the source token that produced the failing
  instruction, when a position table was available (optional)
- `span` - the source text the failing instruction's AST node covers, when the
  program was compiled with spans (optional). `position` names the token to
  blame; `span` is what to underline.
- `details` - structured, error-specific data (optional, default `nil`), the
  same shape `Predicator.Errors.LocationError` already uses. It lets a host
  read machine-readable data off an error without parsing `message`, which is
  non-normative.

## Examples

    %Predicator.Errors.EvaluationError{
      message: "Division by zero",
      reason: "division_by_zero",
      operation: :divide
    }

    %Predicator.Errors.EvaluationError{
      message: "Function len() expects 1 arguments, got 0",
      reason: "insufficient_arguments",
      operation: :function_call
    }

# `t`

```elixir
@type t() :: %Predicator.Errors.EvaluationError{
  details: map() | nil,
  message: binary(),
  operation: atom() | nil,
  position: Predicator.Types.position() | nil,
  reason: binary(),
  span: Predicator.Types.span() | nil
}
```

# `insufficient_operands`

```elixir
@spec insufficient_operands(atom(), integer(), integer()) :: t()
```

Creates an evaluation error for insufficient operands.

# `new`

```elixir
@spec new(binary(), binary(), atom() | nil) :: t()
```

Creates an evaluation error.

# `protected_root`

```elixir
@spec protected_root(binary()) :: t()
```

Creates an evaluation error for a `store` refused by the `:protected_roots`
evaluation option.

`details.root` carries the offending root as data, so a host maps this onto
its own error vocabulary without matching on `message` (messages are
non-normative, `docs/isa.md` §2).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
