[erlang-questions] EEP 47: Syntax in try/catch to retrieve the stacktrace directly

Attila Rajmund Nohl attila.r.nohl@REDACTED
Sun Nov 26 14:40:19 CET 2017


Once I worked with a library that implemented the "let it crash"
philosophy to the maximum - for valid input I got the result, for
invalid input I got function_clause, badarg, badmatch, etc. crashes. I
tried to be clever and match on the output of erlang:get_stacktrace()
to decide if the error came from this particular library or from a
different code (in order to provide more meaningful error message to
the user), but eventually it didn't work out. In that case matching on
the stack trace might have been useful, but as it didn't work out in
the end, I don't think it's such a big deal that I can't match on the
stacktrace.

2017-11-25 15:17 GMT+01:00 Jesper Louis Andersen
<jesper.louis.andersen@REDACTED>:
> I think this is a sensible change all in all, and one which should be done.
>
> My major gripe with it is the fact that you cannot pattern match on the
> stack trace. I see why this is done, but it feels like being a special
> arbitrary rule which goes against other matching patterns in the language.
> I'm not sure how it would help
>
> catch
>    Cl:Err:Stk ->
>         case {Cl, Err, Stk} of
>           ...
> end
>
> What I really like about the change is that it removes get_stacktrace/0
> which is a "bad function", and one of those things I tend to call a
> "language mistake" in Erlang[0].
>
> [0] For the interested, I think one of the most obvious mistakes are that a
> floating point numbers in Erlang cannot express NaNs and Infinities.
>
> On Fri, Nov 24, 2017 at 10:05 AM Björn Gustavsson <bjorn@REDACTED> wrote:
>>
>> There is a new EEP that proposes a new syntax in try/catch to retrieve
>> the stacktrace directly without using erlang:get_stacktrace/0:
>>
>> https://github.com/erlang/eep/blob/master/eeps/eep-0047.md
>>
>> /Björn
>> --
>> Björn Gustavsson, Erlang/OTP, Ericsson AB
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list