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

Richard Carlsson carlsson.richard@REDACTED
Wed Nov 16 17:30:55 CET 2011


On 11/16/2011 05:25 PM, Garrett Smith wrote:
> Mechanically, error exceptions provide a stack trace, exits do not:
>
> Eshell V5.8.5  (abort with ^G)
> 1>  catch(exit(foo)).
> {'EXIT',foo}
> 2>  catch(error(foo)).
> {'EXIT',{foo,[{erl_eval,do_apply,5},
>                {erl_eval,expr,5},
>                {shell,exprs,7},
>                {shell,eval_exprs,7},
>                {shell,eval_loop,3}]}}

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>

    /Richard



More information about the erlang-questions mailing list