A protocol that extends exceptions to be status-code aware.
By default, it looks for an implementation of the protocol, otherwise checks if the exception has the :plug_status
field or simply returns 500.
Receives an exception and returns the possible actions that could be triggered for that error. Should return a list of actions in the following structure
Receives an exception and returns its HTTP status code.
action() :: %{label: String.t(), handler: {module(), atom(), list()}}
t() :: term()
actions(t()) :: [action()]
Receives an exception and returns the possible actions that could be triggered for that error. Should return a list of actions in the following structure:
%{ label: "Text that will be displayed in the button", handler: {Module, :function, [args]} }
Where:
label
a string/binary that names this actionhandler
a MFArgs that will be executed when this action is triggeredIt will be rendered in the Plug.Debugger
generated error page as buttons showing the label
that upon pressing executes the MFArgs defined in the handler
.
defimpl Plug.Exception, for: ActionableExample do def actions(_), do: [%{label: "Print HI", handler: {IO, :puts, ["Hi!"]}}] end
status(t()) :: Plug.Conn.status()
Receives an exception and returns its HTTP status code.
© 2013 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/plug/Plug.Exception.html