[Bps-public-commit] r17458 - in Net-Trac/trunk: .
trs at bestpractical.com
trs at bestpractical.com
Tue Dec 30 18:00:30 EST 2008
Author: trs
Date: Tue Dec 30 18:00:30 2008
New Revision: 17458
Modified:
Net-Trac/trunk/ (props changed)
Net-Trac/trunk/lib/Net/Trac/Connection.pm
Log:
r43277 at zot: tom | 2008-12-30 15:22:25 -0500
Better error handling (trac often returns a 500 + an error page)
Modified: Net-Trac/trunk/lib/Net/Trac/Connection.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Connection.pm (original)
+++ Net-Trac/trunk/lib/Net/Trac/Connection.pm Tue Dec 30 18:00:30 2008
@@ -54,21 +54,28 @@
sub _die_on_error {
my $self = shift;
my $url = shift;
+ my $die = 0;
+
if ( !$self->mech->response->is_success ) {
- die "Server threw an error "
- . $self->mech->response->status_line . " for "
- . $url;
- } elsif (
+ warn "Server threw an error "
+ . $self->mech->response->status_line . " for "
+ . $url;
+ $die++;
+ }
+
+ if (
$self->mech->content =~ qr{
- <div id="content" class="error">
+ <div id="content" class="error">
<h1>(.*?)</h1>
- <p class="message">(.*?)</p>}ismx
+ <p class="message">(.*?)</p>}ism
)
{
- die "$1 $2";
+ warn "$1 $2";
+ $die++;
}
- else { return undef }
+ if ( $die ) { die "Request errored out." }
+ else { return undef }
}
sub ensure_logged_in {
More information about the Bps-public-commit
mailing list