Add a template and functions for signalling user errors (as opposed to internal errors).
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 14 Feb 2005 14:36:07 +0000 (14:36 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 14 Feb 2005 14:36:07 +0000 (14:36 +0000)
html/ccbs.pm
html/do-add-tournament.pl
html/templates/user-error.tmpl [new file with mode: 0644]

index 2b3ea04..7087d5f 100755 (executable)
@@ -68,6 +68,16 @@ sub process_template {
        print $output;
 }
 
+sub user_error {
+       my $msg = shift;
+
+       ccbs::print_header();
+       ccbs::process_template('user-error.tmpl', 'Feil',
+               { message => $msg });
+
+       exit;
+}
+
 $SIG{__DIE__} = sub {
        # Gosh! Net::Resolver::DNS is brain-damaged.
        my $msg = shift;
index ddacad5..02d5e16 100755 (executable)
@@ -16,7 +16,7 @@ my $machine = $cgi->param('machine');
 my $scoringsystem = $cgi->param('scoringsystem');
 
 if ($date !~ /^ ( \d{4} - \d\d - \d\d ) $/x) {
-       die "Ugyldig dato (må være på YYYY-MM-DD)";
+       ccbs::user_error("Ugyldig dato (må være på YYYY-MM-DD).");
 }
 
 $dbh->do('INSERT INTO tournaments (season, tournamentname, country, location, date, machine, scoringsystem) VALUES (?,?,?,?,?,?,?)',
diff --git a/html/templates/user-error.tmpl b/html/templates/user-error.tmpl
new file mode 100644 (file)
index 0000000..3a9a99f
--- /dev/null
@@ -0,0 +1,8 @@
+[%# vim:set filetype=html: %]
+<div>
+  <p>Beklager, det oppsto et problem ved behandlingen av forespørselen din:</p>
+
+  <p><strong>[% message %]</strong></p>
+  
+  <p>Vennligst gå tilbake og prøv igjen.</p>
+</div>