chiark / gitweb /
Error handling and other cleanups
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Aug 2009 19:44:40 +0000 (20:44 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Aug 2009 19:44:40 +0000 (20:44 +0100)
yarrg/web/route
yarrg/web/routetextstring

index 595976f8293a7cde6b6cbe56871ba5e90f47595b..74a5086f1428b64f37e269dd66f3eff07ed999d7 100644 (file)
@@ -76,7 +76,7 @@ foreach my $var (@vars) {
                        my %qf= (%baseqf,%queryqf);
                        delete $qf{$lname};
                        $qf{$lname}= $value if $cvalix;
-                       print '<a href="',&$quri(%qf),'">';
+                       print '<a href="',$quri->(%qf),'">';
                        $after= '</a>';
                }
                print $html, $after;
@@ -100,7 +100,7 @@ $routestring => ''
 </%args>
 
 <h1>Specify route</h1>
-<form action="<% &$quri() %>" method="get">
+<form action="<% $quri->() %>" method="get">
 
 %#---------- textbox, user enters route as string ----------
 % if (!$a{Dropdowns}) {
@@ -201,7 +201,7 @@ while ($row=$sth->fetchrow_arrayref) {
 my %resetislandlistdata;
 foreach my $arch (keys %islandlistdata) {
        $resetislandlistdata{$arch}=
-               &$optionlistmap($islandlistdata{$arch}, '');
+               $optionlistmap->($islandlistdata{$arch}, '');
 }
 
 </%perl>
@@ -229,7 +229,7 @@ function ms_Setarch(dd) {
 <td>
 <select name="archipelago<% $dd %>" onchange="ms_Setarch(<% $dd %>)">
 <option value="none">Whole ocean</option>
-<% &$optionlistmap(\@archlistdata, $ARGS{"archipelago$dd"}) %></select></td>
+<% $optionlistmap->(\@archlistdata, $ARGS{"archipelago$dd"}) %></select></td>
 %      }
 </tr>
 
@@ -239,7 +239,7 @@ function ms_Setarch(dd) {
 %              $arch= 'none' if !defined $arch;
 <td>
 <select name="islandid<% $dd %>">
-<% &$optionlistmap($islandlistdata{$arch}, $ARGS{"islandid$dd"}) %>
+<% $optionlistmap->($islandlistdata{$arch}, $ARGS{"islandid$dd"}) %>
 </select></td>
 %      }
 </tr>
@@ -251,14 +251,19 @@ function ms_Setarch(dd) {
 <input type=submit name=submit value="Go">
 </form>
 
-<h1>Results</h1>
-
 <%perl>
 #========== result computations ==========
 
+my $results_head;
+$results_head= sub {
+       print "<h1>Results</h1>\n";
+       $results_head= sub { };
+};
+
 #---------- result computation - textstring ----------
 if (!$a{Dropdowns}) {
   if (length $routestring) {
+       $results_head->();
        my $rsr= $m->comp('routetextstring',
                ocean => $a{Ocean},
                string => $routestring,
@@ -285,13 +290,14 @@ my $argorundef= sub {
 };
 
 for my $dd (0..$a{Dropdowns}-1) {
-       my $arch= &$argorundef($dd,'archipelago');
-       my $island= &$argorundef($dd,'islandid');
+       my $arch= $argorundef->($dd,'archipelago');
+       my $island= $argorundef->($dd,'islandid');
        next unless defined $arch or defined $island;
        if (defined $island and defined $arch) {
                my $ii= $islandid2{$island};
                my $iarch= $ii->{Arch};
                if ($iarch ne $arch) {
+                       $results_head->();
 </%perl>
  Specified archipelago <% $arch %> but
  island <% $ii->{Name} %>
@@ -308,6 +314,7 @@ for my $dd (0..$a{Dropdowns}-1) {
 </%perl>
 
 % if (@islandids) {
+%      $results_head->();
 
 <& routetrade, islandids => \@islandids, archipelagoes => \@archipelagoes &>
 
index 685b465255325fe566c6ed0f5468b51fa492c711..bf4a4a9988fe9b237736cac3ca06b67353fab4cf 100644 (file)
@@ -48,7 +48,6 @@ foreach my $each (split m#[/|,]#, $string) {
        my $err= sub {
                my $msg= sprintf $_[0], encode_entities($each);
                $output_wrong->($msg);
-               $m->abort();
        };
        my %m;
        my $results;