… | |
… | |
11 | |
11 | |
12 | my $hdl; $hdl = new AnyEvent::Handle |
12 | my $hdl; $hdl = new AnyEvent::Handle |
13 | fh => \*STDIN, |
13 | fh => \*STDIN, |
14 | on_error => sub { |
14 | on_error => sub { |
15 | my ($hdl, $fatal, $msg) = @_; |
15 | my ($hdl, $fatal, $msg) = @_; |
16 | AE::log error => "Got error $msg!"; |
16 | AE::log error => $msg; |
17 | $hdl->destroy; |
17 | $hdl->destroy; |
18 | $cv->send; |
18 | $cv->send; |
19 | }; |
19 | }; |
20 | |
20 | |
21 | # send some request line |
21 | # send some request line |
… | |
… | |
170 | with active (but unsatisfiable) read watchers (C<EPIPE>) or I/O errors. In |
170 | with active (but unsatisfiable) read watchers (C<EPIPE>) or I/O errors. In |
171 | cases where the other side can close the connection at will, it is |
171 | cases where the other side can close the connection at will, it is |
172 | often easiest to not report C<EPIPE> errors in this callback. |
172 | often easiest to not report C<EPIPE> errors in this callback. |
173 | |
173 | |
174 | AnyEvent::Handle tries to find an appropriate error code for you to check |
174 | AnyEvent::Handle tries to find an appropriate error code for you to check |
175 | against, but in some cases (TLS errors), this does not work well. It is |
175 | against, but in some cases (TLS errors), this does not work well. |
176 | recommended to always output the C<$message> argument in human-readable |
176 | |
177 | error messages (it's usually the same as C<"$!">). |
177 | If you report the error to the user, it is recommended to always output |
|
|
178 | the C<$message> argument in human-readable error messages (you don't need |
|
|
179 | to report C<"$!"> if you report C<$message>). |
|
|
180 | |
|
|
181 | If you want to react programmatically to the error, then looking at C<$!> |
|
|
182 | and comparing it against some of the documented C<Errno> values is usually |
|
|
183 | better than looking at the C<$message>. |
178 | |
184 | |
179 | Non-fatal errors can be retried by returning, but it is recommended |
185 | Non-fatal errors can be retried by returning, but it is recommended |
180 | to simply ignore this parameter and instead abondon the handle object |
186 | to simply ignore this parameter and instead abondon the handle object |
181 | when this callback is invoked. Examples of non-fatal errors are timeouts |
187 | when this callback is invoked. Examples of non-fatal errors are timeouts |
182 | C<ETIMEDOUT>) or badly-formatted data (C<EBADMSG>). |
188 | C<ETIMEDOUT>) or badly-formatted data (C<EBADMSG>). |
… | |
… | |
1855 | my ($self, $err) = @_; |
1861 | my ($self, $err) = @_; |
1856 | |
1862 | |
1857 | return $self->_error ($!, 1) |
1863 | return $self->_error ($!, 1) |
1858 | if $err == Net::SSLeay::ERROR_SYSCALL (); |
1864 | if $err == Net::SSLeay::ERROR_SYSCALL (); |
1859 | |
1865 | |
1860 | my $err =Net::SSLeay::ERR_error_string (Net::SSLeay::ERR_get_error ()); |
1866 | my $err = Net::SSLeay::ERR_error_string (Net::SSLeay::ERR_get_error ()); |
1861 | |
1867 | |
1862 | # reduce error string to look less scary |
1868 | # reduce error string to look less scary |
1863 | $err =~ s/^error:[0-9a-fA-F]{8}:[^:]+:([^:]+):/\L$1: /; |
1869 | $err =~ s/^error:[0-9a-fA-F]{8}:[^:]+:([^:]+):/\L$1: /; |
1864 | |
1870 | |
1865 | if ($self->{_on_starttls}) { |
1871 | if ($self->{_on_starttls}) { |