]> git.sesse.net Git - ccbs/commitdiff
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 2b3ea04e56fa95b8da5414e8cf09dd72a693c96d..7087d5f29742c594e376416ff665a8a620a3449f 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 ddacad5c8677b34a9ad6ed88d517bb2424a6d09d..02d5e167b7713d946bfac3787ba6a8a4c8bef004 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>