diff options
author | francis <francis> | 2006-09-25 16:08:06 +0000 |
---|---|---|
committer | francis <francis> | 2006-09-25 16:08:06 +0000 |
commit | 99a93f079d6248b9371f152ff32f9b71a0cf7770 (patch) | |
tree | 88c8cf36ff38eb6775ca5c01abc6796af7972eec | |
parent | 93b8742f008d1bdbcf35db6d9cd666335d79412a (diff) |
Improve error handling
-rwxr-xr-x | web/index.cgi | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/web/index.cgi b/web/index.cgi index b5dad26c4..91a130856 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: index.cgi,v 1.21 2006-09-22 18:31:25 matthew Exp $ +# $Id: index.cgi,v 1.22 2006-09-25 16:08:06 francis Exp $ use strict; require 5.8.0; @@ -19,6 +19,7 @@ use Error qw(:try); use LWP::Simple; use RABX; use POSIX qw(strftime); +use CGI::Carp; use Page; use mySociety::Config; @@ -64,7 +65,6 @@ sub main { } else { $out = front_page(); } - print Page::header($q, ''); print $out; print Page::footer($q); @@ -396,8 +396,9 @@ EOF sub display_map { my ($q, $x, $y, $type, $compass) = @_; my $url = mySociety::Config::get('TILES_URL'); - my $tiles = $url . $x . '-' . ($x+1) . ',' . $y . '-' . ($y+1) . '/RABX'; - $tiles = LWP::Simple::get($tiles); + my $tiles_url = $url . $x . '-' . ($x+1) . ',' . $y . '-' . ($y+1) . '/RABX'; + my $tiles = LWP::Simple::get($tiles_url); + throw Error::Simple("Unable to get tiles from URL $tiles_url") if !$tiles; my $tileids = RABX::unserialise($tiles); my $tl = $x . '.' . ($y+1); my $tr = ($x+1) . '.' . ($y+1); @@ -449,11 +450,11 @@ sub postcode_check { $areas = mySociety::MaPit::get_voting_areas($pc); # Check for London Borough - throw RABX::Error("I'm afraid that postcode isn't in our covered area.", 123456) if (!$areas || !$areas->{LBO}); + throw Error::Simple("I'm afraid that postcode isn't in our covered area.", 123456) if (!$areas || !$areas->{LBO}); # Check for Lewisham or Newham my $lbo = $areas->{LBO}; - throw RABX::Error("I'm afraid that postcode isn't in our covered London boroughs.", 123457) unless ($lbo == 2510 || $lbo == 2492); + throw Error::Simple("I'm afraid that postcode isn't in our covered London boroughs.", 123457) unless ($lbo == 2510 || $lbo == 2492); my $area_info = mySociety::MaPit::get_voting_area_info($lbo); my $name = $area_info->{name}; |