Doc or gen_event:notify/2 Error!
Lennart Öhman
lennart.ohman@REDACTED
Wed Sep 10 17:51:12 CEST 2003
Hi,
not claiming to have the perfect answer or solution but. Many other
OTP client/server functions crash if something goes wrong. For instance
if you have a time-out on a call.
Then there is already a difference in the behaviour in Erlang between
sending to a non existing PID and a non existing name. The first is
legal but the second causes a run-time error. One can then argue that
the call function shall follow this anomaly since it is what an Erlang
programmer may expect.
/Lennart
Martin J. Logan wrote:
> I will catch the error then. I think that having to take measures to
> avoid a crash produced by my asynchronous call seems to run counter to
> the spirit of asynchronous communication. Though I could be missing some
> overriding reason to let it exit.
>
>
> On Wed, 2003-09-10 at 01:08, Gunilla Arendt wrote:
>
>>Snip from the gen_event man page:
>>
>>"Unless otherwise stated, all functions in this module fail
>> if the specified event manager does not exist or if bad
>> arguments are given"
>>
>>The same goes for gen_server and gen_fsm.
>>
>>Regards, Gunilla
>>
>>"Martin J. Logan" wrote:
>>
>>>Hello,
>>> I have found an inconsistency in the docs.
>>>
>>>The docs indicate that the return value for gen_event notify is as
>>>follows:
>>>
>>>notify(EventMgrRef, Event) -> ok
>>>
>>>This makes sense as it is asynchronous. I pass a registered name to a
>>>notify call and if the name is not registered I get an exit(). It is the
>>>same badarg exit that one would expect from
>>>
>>>unregistered_name ! message
>>>
>>>I think that either the docs should be changed to
>>>
>>>notify(EventMgrRef, Event) -> ok | exit()
>>>
>>>or more preferably the notify/2 function should not exit.
>>>
>>>Cheers,
>>>Martin
>>>
>>>OUTPUT:
>>>
>>>gen_event:notify(martin, martin).
>>>
>>>=ERROR REPORT==== 9-Sep-2003::17:05:56 ===
>>>Error in process <0.31.0> with exit value:
>>>{badarg,[{gen_event,send,2},{erl_eval,do_apply,5},{shell,eval_loop,2}]}
>>>
>>>** exited: {badarg,[{gen_event,send,2},
>>> {erl_eval,do_apply,5},
>>> {shell,eval_loop,2}]} **
>
>
--
-------------------------------------------------------------
Lennart Ohman phone : +46-8-587 623 27
Sjoland & Thyselius Telecom AB cellular: +46-70-552 6735
Sehlstedtsgatan 6 fax : +46-8-667 8230
SE-115 28 STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED
More information about the erlang-questions
mailing list