- What headers do you have? Have you sent
Accept: application/json? - Matching by template name is invalid. In case of 404, the template is the following:
404.json, noterror.json. - The second parameter is not an exception, but
assigns. The exception could be found inassigns.reason.
If you want generic handler for JSON format:
def render(<<_::binary-size(3)>> <> ".json" = template, assigns) do
%{
error: Phoenix.Controller.status_message_from_template(template),
description: Exception.message(assigns.reason)
}
end
but don’t show a message from all exceptions, as they may contain not public information






















