Created
April 4, 2016 21:40
-
-
Save nsomar/96f62ee12b0fe9769785c0c0a200d50b to your computer and use it in GitHub Desktop.
Handling errors with `with`
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
res = | |
with {:ok} <- validate_request(request), | |
{:ok, user} <- get_user(request), | |
{:ok} <- update_db(user), | |
{:ok} <- send_email(user) do | |
return_http_message | |
end | |
case res do | |
{:error, x} -> IO.inspect("Error: " <> x) | |
_ -> {:ok} #Success | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment