summaryrefslogtreecommitdiff
path: root/lib/Travel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travel')
-rw-r--r--lib/Travel/Status/DE/VRR.pm26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/Travel/Status/DE/VRR.pm b/lib/Travel/Status/DE/VRR.pm
index a108425..02985a7 100644
--- a/lib/Travel/Status/DE/VRR.pm
+++ b/lib/Travel/Status/DE/VRR.pm
@@ -59,14 +59,22 @@ sub new {
},
};
+ bless( $self, $class );
+
$mech->post( 'http://efa.vrr.de/vrr/XSLT_DM_REQUEST', $self->{post} );
if ( $mech->response->is_error ) {
- confess( $mech->response->status_line );
+ $self->{errstr} = $mech->response->status_line;
+ return $self;
}
my $form = $mech->form_number(1);
+ if ( not $form ) {
+ $self->{errstr} = 'Unable to find the form - no lines returned?';
+ return $self;
+ }
+
for my $input ( $form->find_input( 'dmLineSelection', 'option' ) ) {
$input->check();
}
@@ -74,7 +82,8 @@ sub new {
$mech->click('submitButton');
if ( $mech->response->is_error ) {
- confess( $mech->response->status_line );
+ $self->{errstr} = $mech->response->status_line;
+ return $self;
}
$self->{html} = $mech->response->decoded_content;
@@ -86,7 +95,13 @@ sub new {
suppress_warnings => 1,
);
- return bless( $self, $class );
+ return $self;
+}
+
+sub errstr {
+ my ($self) = @_;
+
+ return $self->{errstr};
}
sub results {
@@ -188,6 +203,11 @@ address / poi / stop name to list departures for.
=back
+=item $status->errstr
+
+In case of an error in the HTTP requests, returns a string describing it. If
+no error occured, returns undef.
+
=item $status->results
Returns a list of Travel::Status::DE::VRR::Result(3pm) objects, each one describing