I update my previous post while you made this one to make it clear, but here it his again:
# file: lib/yourapp_web/router.ex
pipeline :api do
plug :accepts, ["json"],
plug :handle_errors
end
# you may need to pattern match in `conn.status` to make this work
def handle_errors(conn, %{kind: _kind, reason: _reason, stack: _stack}) do
# You may need to use the Jason library if returning only the map doesn't work.
# You also want to put the `application/json` header in the `conn`
send_resp(conn, conn.status,%{error: conn.status, message: "Something went wrong"})
end
This is a guess from me, not actually tried it.
EDIT: On a second though I think this isn’t reflecting the intended use from the Plug.ErrorHandler






















