Closed kak-tus closed 8 years ago
User can subscribe on error event, but in case of error in asynchronous operation it can't emitted.
Use case: If we using many asynchronous functions with different requests, we must check and log error in any function.
sub sub1 { $pg->db->query('select 1', sub { my ( $db, $error, $results ) = @_; if ($error) { $logger->error($error); } } ); } sub sub2 { $pg->db->query('select 2', sub { my ( $db, $error, $results ) = @_; if ($error) { $logger->error($error); } } ); }
In case of error emitting we can have one global callback to log errors
$pg->on( error => sub { my ( $e, $err ) = @_; $logger->error($err); } );
No.
Sorry, but the use case doesn't convince me, and the behavior is inconsistent with other modules like Mojo::UserAgent. 👎
Mojo::UserAgent
Thanks for your contribution, but i'm afraid this pull request did not pass the vote.
Summary
User can subscribe on error event, but in case of error in asynchronous operation it can't emitted.
Use case: If we using many asynchronous functions with different requests, we must check and log error in any function.
In case of error emitting we can have one global callback to log errors
References
No.