[PATCH] AnyEvent::Handle

Maxime Soulé btik-cpan at scoubidou.com
Tue Jul 3 12:00:36 CEST 2012

Le 03.07.2012 11:02, Marc Lehmann a écrit :
> On Tue, Jul 03, 2012 at 10:55:56AM +0200, Maxime Soulé<btik-cpan at scoubidou.com>  wrote:
>> If an exception is thrown by the callback, it will be trapped and
>> assimilated to a "Bad Message", which is wrong...
> hmm why?

Because this behavior is not consistent across all type readers. With 
JSON, for example, an exception in the callback is not caught as a "Bad 

>> I think that exceptions thrown by the callback should not be caught
>> at this level.
> It doesn't matter, as callbacks must not throw exceptions without catching
> them themselves. If they do, they are already buggy and invoke undefined
> behaviour - causing EBADMSG is then the least of the problems.

I have in mind general application exceptions, like a perl critical one. 
I prefer to handle this fatal case at the application level than to hide 
it behind an error code EBADMSG and continuing to work.

> In fact, if caught via this mechanism it at least has a chance of getting
> reported in a defined way (although it's still a bug).

Or not, as EBADMSG is an error related to the handled connection, not to 
the application.

When an EBADMSG is reported, it says that probably the client sent wrong 
data, so we can disconnect it and continue to work.

In the application fatal error case, it is not the same, the problem can 
be (and is probably) more serious...

Best regards,


More information about the anyevent mailing list