aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Around.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm15
1 files changed, 10 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index b872084ff..30c023317 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -8,6 +8,7 @@ use FixMyStreet::Map;
use Encode;
use JSON::MaybeXS;
use Utils;
+use Try::Tiny;
=head1 NAME
@@ -366,13 +367,17 @@ sub lookup_by_ref : Private {
external_id => $ref
]);
- if ( $problems->count == 0) {
- $c->detach( '/page_error_404_not_found', [] );
- } elsif ( $problems->count == 1 ) {
- $c->res->redirect( $c->uri_for( '/report', $problems->first->id ) );
- } else {
+ my $count = try {
+ $problems->count;
+ } catch {
+ 0;
+ };
+
+ if ($count > 1) {
$c->stash->{ref} = $ref;
$c->stash->{matching_reports} = [ $problems->all ];
+ } elsif ($count == 1) {
+ $c->res->redirect( $c->uri_for( '/report', $problems->first->id ) );
}
}