# `Oaskit.ErrorHandler`
[🔗](https://github.com/lud/oaskit/blob/v0.13.1/lib/oaskit/error_handler.ex#L1)

A behaviour for validation errors handlers.

# `reason`

```elixir
@type reason() ::
  Oaskit.Errors.InvalidBodyError.t()
  | Oaskit.Errors.UnsupportedMediaTypeError.t()
  | {:parameters_errors,
     [
       Oaskit.Errors.InvalidParameterError.t()
       | Oaskit.Errors.MissingParameterError.t()
     ]}
```

# `handle_error`

```elixir
@callback handle_error(Plug.Conn.t(), reason(), arg :: term()) :: Plug.Conn.t()
```

Accepts the Plug.Conn struct, an error reason and the options passed to the
`Oaskit.Plugs.ValidateRequest` plug.

This function is called when request validation fails and an error must be
returned to the remote client. This means that function _must_ send a
response.

Responses can be sent just as in Phoenix controllers, using
`Plug.Conn.send_resp/3`, `Phoenix.Controller.json/2`,
`Phoenix.Controller.text/2`, _etc._

The `arg` argument is the options given to `Oaskit.Plugs.ValidateRequest`. See
this module documentation for more information.

---

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