-
-
Save marciol/ea37747aaf681d88b3e9fd11f5c05217 to your computer and use it in GitHub Desktop.
Handling errors with `with`
This file contains hidden or 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