elixir-plug / plug

Compose web applications with functions
https://hex.pm/packages/plug
Other
2.88k stars 586 forks source link

Plug.ErrorHandler mentions 'callbacks' but there is no behaviour #1020

Closed victorolinasc closed 3 years ago

victorolinasc commented 3 years ago

Documentation of Plug.ErrorHandler mentions this:

Once this module is used, a callback named handle_errors/2 should be defined in your plug. This callback will receive the connection already updated with a proper status code for the given exception.

Since this callback is a public function and is not defined in a behaviour it feels like it needs a docstring. I think a @callback definition plus a @behaviour would be a "better" documentation as to what that function actually does. Just adding a @impl Plug.ErrorHandler would improve code navigation there and awareness of its functionality.

If you are not against this I can open a PR for that. Otherwise sorry for the noise :) It seems like a bug to me.

josevalim commented 3 years ago

PR is welcome!