# `AshJido.Error`
[🔗](https://github.com/agentjido/ash_jido/blob/v1.0.0/lib/ash_jido/error.ex#L1)

Facade for converting Ash errors to Jido.Action.Error Splode-based errors.

This module provides utilities to transform Ash Framework error types into
the Jido Action error system, preserving error details and providing
consistent error handling across the Ash-Jido integration.

# `extract_changeset_errors`

```elixir
@spec extract_changeset_errors(Exception.t()) :: [map()]
```

Extracts changeset-specific error information.

Returns a list of maps containing error type, message, and details
for errors related to changesets or validations.

# `extract_field_errors`

```elixir
@spec extract_field_errors(Exception.t()) :: %{required(atom()) =&gt; [String.t()]}
```

Extracts field-specific errors for validation feedback.

Returns a map where keys are field names and values are lists of
error messages for that field.

# `extract_underlying_errors`

```elixir
@spec extract_underlying_errors(Exception.t()) :: [Exception.t()]
```

Extracts the list of underlying errors from an Ash error.

Ash errors often wrap multiple underlying errors. This function
extracts them for detailed error inspection.

# `from_ash`

```elixir
@spec from_ash(Exception.t()) :: Exception.t()
```

Converts an Ash error to a Jido.Action.Error.

Pattern matches on different Ash error types and converts them to appropriate
Jido error constructors:

- `Ash.Error.Invalid` → validation_error
- `Ash.Error.Forbidden` → execution_error with reason :forbidden
- `Ash.Error.Framework` → internal_error
- `Ash.Error.Unknown` → internal_error
- Other exceptions → execution_error

The original Ash error is preserved in the details map under the `:ash_error` key.

## Examples

    iex> AshJido.Error.from_ash(%Ash.Error.Invalid{errors: []})
    %Jido.Action.Error.InvalidInputError{...}

    iex> AshJido.Error.from_ash(%Ash.Error.Forbidden{errors: []})
    %Jido.Action.Error.ExecutionFailureError{...}

---

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