There is a way to specify http status code and plug will intercept the exception and show the error message with the specified status code or something like that. That’s how ecto exceptions work in phoenix.
So, you either need to define an implementation for the exception
defimpl Plug.Exception, for: Your.Error do
def status(_exception), do: 400 # or anything else
end
or have a :plug_status field in the exception.
defmodule Your.Error do
defexception [message: "...", plug_status: 400]
end