[erlang-questions] stdlib shell_catch_exception ?

Steve Vinoski vinoski@REDACTED
Sat Oct 17 01:27:48 CEST 2015


On Fri, Oct 16, 2015 at 7:24 PM, PAILLEAU Eric <eric.pailleau@REDACTED>
wrote:

>
> (Really useful if you're doing ETS work in the shell.)
>>
>>
> Hi,
>  thanks ! make sens now. What puzzled me is that exception message was
> raised both case, but shell is killed and restarted by supervisor if
> 'false' and stay alive if 'true'.


You can just say catch_exception, passing it a boolean argument:

1> self().
<0.33.0>
2> catch_exception(true).
false
3> 1/0.
* exception error: an error occurred when evaluating an arithmetic
expression
    in operator  '/'/2
       called as 1 / 0
4> self().
<0.33.0>

Also useful for working with sockets, since opening a socket in the shell
and then having the shell die means the socket gets closed.

--steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151016/65c390af/attachment.htm>


More information about the erlang-questions mailing list