Commit 4c0dc86a authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

cgi: Error handling

parent 731a744d
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ sub get_results_for {
	my $results = $cache->thaw($station);

	if ( not $results ) {
		my $status = Travel::Status::DE::DeutscheBahn->new( station => $station
		);
		my $status
		  = Travel::Status::DE::DeutscheBahn->new( station => $station );
		$results = [ $status->results ];
		$cache->freeze( $station, $results );
	}
@@ -43,8 +43,14 @@ get '/multi/:station' => sub {
		filename          => dist_file( 'db-fakedisplay', 'multi-lcd.html' ),
		loop_context_vars => 1,
	);
	my @results = get_results_for($station);

	if ( not @results ) {
		$self->render( 'index', error => "Got no results for '$station'", );
		return;
	}

	for my $result ( get_results_for($station) ) {
	for my $result (@results) {
		push(
			@params,
			{
@@ -68,7 +74,7 @@ __DATA__

@@ index.html.ep
% title 'DB Fakedisplay';
<% if (my $error = flash 'error' ) { %>
<% if (my $error = stash 'error') { %>
  Error: <%= $error %><br/>
<% } %>
<%= form_for index => begin %>