Created
April 29, 2015 13:51
-
-
Save AntonFagerberg/716f9bfbcc53f7a34003 to your computer and use it in GitHub Desktop.
Plug handle errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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