summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Controller/Stationboard.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2023-02-12 18:02:31 +0100
committerDaniel Friesel <derf@finalrewind.org>2023-02-12 18:02:31 +0100
commit21db75aa35f08c86458481dacd06638c68f1318c (patch)
treed2bee15b1f6ae655c9e0830a682237181eb087b9 /lib/DBInfoscreen/Controller/Stationboard.pm
parentdc24eeee22fe56f50977f1ba15af699b2275d42c (diff)
handle_no_results: return HTTP 500 when called from an exception handler
Diffstat (limited to 'lib/DBInfoscreen/Controller/Stationboard.pm')
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm37
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 05d4afb..317ed74 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -65,7 +65,7 @@ sub handle_no_results {
error => $err,
stationlist => \@candidates,
hide_opts => 0,
- status => 300,
+ status => $data->{status} // 300,
);
return;
}
@@ -75,7 +75,8 @@ sub handle_no_results {
$self->render(
'landingpage',
error => ( $err // "Keine Abfahrten an '$station'" ),
- hide_opts => 0
+ hide_opts => 0,
+ status => $data->{status} // 500,
);
return;
}
@@ -96,7 +97,7 @@ sub handle_no_results {
'landingpage',
stationlist => \@candidates,
hide_opts => 0,
- status => 300,
+ status => $data->{status} // 300,
);
return;
}
@@ -106,14 +107,16 @@ sub handle_no_results {
'landingpage',
error => ( $errstr // "Keine Abfahrten an '$station'" )
. '. Das von DBF genutzte IRIS-Backend unterstützt im Regelfall nur innerdeutsche Zugfahrten.',
- hide_opts => 0
+ hide_opts => 0,
+ status => $data->{status} // 200,
);
return;
}
$self->render(
'landingpage',
error => ( $errstr // "Keine Abfahrten an '$station'" ),
- hide_opts => 0
+ hide_opts => 0,
+ status => $data->{status} // 404,
);
return;
}
@@ -158,12 +161,13 @@ sub handle_no_results_json {
$json = $self->render_to_string( json => $json );
$self->render(
data => "$callback($json);",
- format => 'json'
+ format => 'json',
);
}
else {
$self->render(
- json => $json,
+ json => $json,
+ status => $data->{status} // 300,
);
}
return;
@@ -492,11 +496,24 @@ sub handle_request {
sub {
my ($err) = @_;
if ( $template eq 'json' ) {
- $self->handle_no_results_json( $station, { errstr => $err },
- $api_version );
+ $self->handle_no_results_json(
+ $station,
+ {
+ errstr => $err,
+ status => 500
+ },
+ $api_version
+ );
return;
}
- $self->handle_no_results( $station, { errstr => $err }, $hafas );
+ $self->handle_no_results(
+ $station,
+ {
+ errstr => $err,
+ status => 500
+ },
+ $hafas
+ );
return;
}
)->wait;