CC: | gisle [...] ActiveState.com |
Subject: | How to distinguish error types ? |
Date: | Thu, 13 Sep 2007 14:59:20 +0200 |
To: | bug-libwww-perl [...] rt.cpan.org |
From: | Sebastiano Piccoli <sebastiano.piccoli [...] dada.net> |
Hi,
we use LWP::UserAgent in a large scale application and I have a question.
Actually in UserAgent.pm when the connection with web server failed in
the sub send_request:
$response = $protocol->request($request, $proxy, $arg, $size, $timeout);
send_request return a $response with a generic Internal Server Error
code and a description of the error.
What we need to distinguish are these two cases:
- failure of _new_socket in LWP::Protocol::http or LWP::Protocol::https
- failure of other types in the continuation of the request
The reason is that we have to be sure that web server is not responding
at all and nothing has been sent.
I know there is yet a string of description:
die "Can't connect to $host:$port ($@)";
but is there a way to distinguish the error ?
For example adding an header in the sub _new_response that contains a
different code ?
Thanks
Sebastiano