[erlang-questions] When to return {ok, Value} or just the Value

Steve Davis <>
Thu Nov 17 00:07:30 CET 2011


Probably just me, but "case catch()" seems more natural in erlang than
"try... catch", (much for the same reasons that I prefer a case
statement to the weird "if" in erlang which IMHO should also be
removed to avoid pollution).

And WRT to the original question I think my "rule of thumb" is now
guided by Ulf's insightful response of "All success values must be
clearly distinguishable from the error values."

On Nov 16, 10:30 am, Richard Carlsson <>
wrote:
> Only in the way the crappy old 'catch' operator presents it. The stack
> trace is available also for exits and throws, if you ask for it:
>
> Eshell V5.8.4  (abort with ^G)
> 1>  catch(exit(foo)).
> {'EXIT',foo}
> 2> erlang:get_stacktrace().
> [{erl_eval,do_apply,5},
>   {erl_eval,expr,5},
>   {shell,exprs,7},
>   {shell,eval_exprs,7},
>   {shell,eval_loop,3}]
> 3>



More information about the erlang-questions mailing list