[erlang-bugs] rpc:call hide throw
Eric Merritt
ericbmerritt@REDACTED
Mon May 14 16:31:47 CEST 2012
Just to throw my 2c and agree with the original poster. Regardless of
whether exceptions are encouraged or not, the fact is that thrown
exceptions are a documented part of the language, and for rpc:call not
to return some indicator of the excepted state is broken.
I would equate this to the use of 'catch'. The argument against that
use that you can't tell valid return values from thrown return values.
The solution is "don't use catch, use one of the try forms". That
same argument would seem to apply here. However, In this case there is
no form that propagates the exception in any way. Perhaps some
additional rpc:call_<x> or rpc:<x>_call needs to be added that either
propagates the exception as an exception (problematic I know) or wraps
all values in a tuple in the normal erlang way. `{ok, <valid-result>}`
or `{exit | throw | error, <thrown-value>}`.
On Mon, May 14, 2012 at 9:17 AM, Vyacheslav Vorobyov <vjache@REDACTED> wrote:
> Let me disagree with "erlang:throw/1 does not generate an exception".
>
> Am I wrong addressing you to
> http://www.erlang.org/doc/reference_manual/errors.html#id81437. I
> think it does generate exception of class 'throw' ;-)
>
> About "We don't throw errors in erlang.", probably yes, but we also
> don't want to loose (hide) information when using rpc:call.
> Information about HOW value returned. Currently rpc:call provides us
> with doubtful "service" it decides for us that normally returned value
> and thrown one are "equally good".
>
> 2012/5/14 Robert Virding <robert.virding@REDACTED>:
>> erlang:throw/1 does not generate an exception or error, it does a non-local return from a function up to a surrounding catch or try. In this sense this is not an unreasonable return value, it behaves as if there is an implicit catch. If it were to generate an error it would be a 'nocatch' error. See
>>
>> http://www.erlang.org/doc/man/erlang.html#throw-1
>>
>> We don't throw errors in erlang. :-)
>>
>> Robert
>>
>> ----- Original Message -----
>>> ---------- Forwarded message ----------
>>> From: Vyacheslav Vorobyov <vjache@REDACTED>
>>> Date: 2012/5/11
>>> Subject: rpc:call hide throw
>>> To: erlang-bugs@REDACTED
>>>
>>>
>>> Hello,
>>>
>>> % 1. Good behavior
>>> {badrpc,{'EXIT', some_reson }} =
>>> rpc:call(node(),erlang,exit,[some_reson]).
>>>
>>> % 2. Bad behavior
>>> some_reson = rpc:call(node(),erlang,throw,[some_reson]).
>>>
>>> The second case describes an issue. It makes indistinguishable normal
>>> result from exception.
>>>
>>>
>>> --
>>> Best Regargs,
>>> Vyacheslav
>>>
>>>
>>> --
>>> Best Regargs,
>>> Vyacheslav
>>> _______________________________________________
>>> erlang-bugs mailing list
>>> erlang-bugs@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-bugs
>>>
>
>
>
> --
> Best Regargs,
> Vyacheslav
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
More information about the erlang-bugs
mailing list