Skip to content

Instantly share code, notes, and snippets.

@Mike-Dunton
Last active October 26, 2015 18:05
Show Gist options
  • Select an option

  • Save Mike-Dunton/e01817880e56fbc7c6da to your computer and use it in GitHub Desktop.

Select an option

Save Mike-Dunton/e01817880e56fbc7c6da to your computer and use it in GitHub Desktop.
Exploring the try catch in erlang
-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