summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-22 20:52:04 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-22 20:52:04 +0200
commit6dabe27e6e73c18988f3bff2a34f23d038708ca0 (patch)
treebb34c9c7e35c4efdc55b9aa698698ee949d5da8c /lib
parent33dda200871e1819e272754354d6b7ac4423c94c (diff)
train details: proper error message3.3.2
Diffstat (limited to 'lib')
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 9efe0c3..2013669 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -260,10 +260,12 @@ sub handle_request {
$opt{with_related} = 1;
}
- if ($self->param('train')) {
+ if ( $self->param('train') ) {
+
# request results from five minutes ago to avoid train details suddenly
# becoming unavailable when its scheduled departure is reached.
- $opt{datetime} = DateTime->now(time_zone => 'Europe/Berlin')->subtract(minutes => 20);
+ $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' )
+ ->subtract( minutes => 20 );
$opt{lookahead} = 200;
}
@@ -661,14 +663,18 @@ sub train_details {
$self->stash( title => 'DBF' );
$self->stash( version => $dbf_version );
- $opt{datetime} = DateTime->now(time_zone => 'Europe/Berlin')->subtract(minutes => 20);
+ $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' )
+ ->subtract( minutes => 20 );
$opt{lookahead} = 200;
my $data = get_results_for( 'iris', $station, %opt );
my $errstr = $data->{errstr};
if ( not @{ $data->{results} } ) {
- $self->handle_no_results( 'iris', $station, $errstr );
+ $self->render(
+ 'landingpage',
+ error => "Keine Abfahrt von $train_no in $station gefunden",
+ );
return;
}
@@ -676,8 +682,10 @@ sub train_details {
= grep { result_is_train( $_, $train_no ) } @{ $data->{results} };
if ( not $result ) {
- $self->handle_no_results( 'iris', $station,
- "Zug $train_no nicht gefunden" );
+ $self->render(
+ 'landingpage',
+ error => "Keine Abfahrt von $train_no in $station gefunden",
+ );
return;
}