Skip to content

Instantly share code, notes, and snippets.

@AntonFagerberg
Created April 29, 2015 13:51
Show Gist options
  • Save AntonFagerberg/716f9bfbcc53f7a34003 to your computer and use it in GitHub Desktop.
Save AntonFagerberg/716f9bfbcc53f7a34003 to your computer and use it in GitHub Desktop.
Plug handle errors
get "/throw-test-1" do
throw :some_failure
end
get "/throw-test-2" do
Task.start_link(fn -> throw :some_failure end)
# Wait for task in some way
end
defp handle_errors(conn, %{kind: _kind, reason: _reason, stack: _stack} = hej) do
send_resp(conn, conn.status, "Something went wrong")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment