Last active
October 26, 2015 18:05
-
-
Save Mike-Dunton/e01817880e56fbc7c6da to your computer and use it in GitHub Desktop.
Exploring the try catch in erlang
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
| -module(tryCatchTest). | |
| -export([start/0]). | |
| -export([start_two/0]). | |
| start() -> | |
| function_one(). | |
| start_two() -> | |
| try function_one() of | |
| ok -> | |
| io:fwrite("Everything is Awesome") | |
| catch | |
| _:Error -> | |
| io:fwrite("I caught the error that happened in function one\n"), | |
| io:fwrite("error: ~p \n", [Error]) | |
| end. | |
| function_one() -> | |
| try function_two() of | |
| ok -> | |
| io:fwrite("Function Two SAID OK!\n") | |
| catch | |
| _:Error -> | |
| io:fwrite("We caught an error in function_two\n"), | |
| io:fwrite("error: ~p \n", [Error]) | |
| end. | |
| function_two() -> | |
| {error, every_thing_is_not_ok}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment