Oaskit.ErrorHandler behaviour (oaskit v0.3.0)
View SourceA behaviour for validation errors handlers.
Summary
Callbacks
Accepts the Plug.Conn struct, an error reason and the options passed to the
Oaskit.Plugs.ValidateRequest
plug.
Types
@type reason() :: Oaskit.Errors.InvalidBodyError.t() | Oaskit.Errors.UnsupportedMediaTypeError.t() | {:parameters_errors, [ Oaskit.Errors.InvalidParameterError.t() | Oaskit.Errors.MissingParameterError.t() ]}
Callbacks
@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.