[erlang-questions] Non-typed errors in catch
John Krukoff
jkrukoff@REDACTED
Thu May 16 19:38:41 CEST 2019
I’ve no insight into why the set of valid exception classes isn’t restricted to the 3 the run time can actually create, but can at least point to the explanation of why `catch Error ->` is valid:
> It is allowed to omit Class and Stacktrace. An omitted Class is shorthand for throw:
from: http://erlang.org/doc/reference_manual/expressions.html#try
And illustrated by:
```
> try throw(broke) catch Error -> {throw, Error} end.
{throw,broke}
```
--
John Krukoff
jkrukoff@REDACTED
From: erlang-questions-bounces@REDACTED <erlang-questions-bounces@REDACTED> On Behalf Of Salikhov Dinislam
Sent: Thursday, May 16, 2019 10:08
To: Erlang/OTP discussions <erlang-questions@REDACTED>
Subject: [erlang-questions] Non-typed errors in catch
Hello,
I have the following module:
-module(exception).
-export([
foo/1
]).
foo(Any) ->
try Any + 1 of
Any -> ok
catch
Error -> {not_typed, Error}; % warn?
any:Error -> {any_error, Error}; % warn?
Type:Error -> {typed_error, {Type, Error}}
end.
Compiler doesn't complain about the marked lines. Neither does dialyzer.
Is there any rationale for such behaviour? Or is it a bug?
P.S. I use Erlang/OTP 20 [erts-9.3.2].
Regards,
Dinislam Salikhov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6290 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190516/50b334e7/attachment.bin>
More information about the erlang-questions
mailing list