I’m having some trouble getting a simple example to work. I’m not using Phoenix FWIW, just plug
defmodule Unauthorized do
defexception message: "not authorized", plug_status: 401
end
defmodule Foo do
use Plug.Router
plug :match
plug :dispatch
get "/" do
send_resp(conn, 200, "heyyyo")
end
get "/boom" do
raise Unauthorized
end
match _ do
send_resp(conn, 404, "not found")
end
end
This is kind of a silly example, but I’m just trying to see if it will work like I think it is supposed to work.
I was hoping that Plug would handle the exception raised in GET /boom
and return a 401 status
However, when I do try to GET /boom
it is returning a 500 status, so apparently the exception isn’t being handled by Plug