--- cvsroot/AnyEvent-MP/MP.pm 2012/03/10 20:34:11 1.132 +++ cvsroot/AnyEvent-MP/MP.pm 2012/03/12 10:34:06 1.133 @@ -401,7 +401,8 @@ sub rcv($@); my $KILME = sub { - die "received message on port without callback"; + (my $tag = substr $_[0], 0, 30) =~ s/([\x20-\x7e])/./g; + kil $SELF, unhandled_message => "no callback set for message (first element $tag)"; }; sub port(;&) { @@ -423,7 +424,7 @@ executing the callback. Runtime errors during callback execution will result in the port being Ced. -The default callback received all messages not matched by a more specific +The default callback receives all messages not matched by a more specific C match. =item rcv $local_port, tag => $callback->(@msg_without_tag), ... @@ -734,7 +735,17 @@ Transport/communication errors are reported as C<< transport_error => $message >>. -=cut +Common idioms: + + # silently remove yourself, do not kill linked ports + kil $SELF; + + # report a failure in some detail + kil $SELF, failure_mode_1 => "it failed with too high temperature"; + + # do not waste much time with killing, just die when something goes wrong + open my $fh, "