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

The default error handler for validation errors.

Returns various HTTP error codes depending on the validation failure:

* `422`
  _Unprocessable Content_ - When JSON
  schema errors when validating request bodies.
* `415`
  _Unsupported Media Type_ -
  When matching the request content-type to the accepted content-types.
* `400`
  _Bad Request_ - When
  validating query and path parameters.

## Error formatting

For request specifically accepting HTML (`"html"` is found in the Accept
header), this handler will present errors in an HTML document with basic
styles.

In any other case, a JSON representation of errors is returned with the
`"application/json"` content type.

Disable HTML entirely with the `html_errors: false` option when using the
`Oaskit.Plugs.ValidateRequest` plug.

# `error_response_schema`

Returns a module-based JSON schema for json responses returned by this module
when used as the handler of validation errors.

### Example

    operation :my_action,
      request_body: UserCreationParams,
      responses: [
        ok: User,
        default: Oaskit.ErrorHandler.Default.error_response_schema()
      ]

    def my_action(conn, params) do
      # ...
    end

# `handle_error`

---

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