]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 162066 - Fix callers of ThrowCodeError to use messages in code-error.html.tmpl...
authorgerv%gerv.net <>
Thu, 15 Aug 2002 13:43:44 +0000 (13:43 +0000)
committergerv%gerv.net <>
Thu, 15 Aug 2002 13:43:44 +0000 (13:43 +0000)
CGI.pl
post_bug.cgi
process_bug.cgi
template/en/default/global/code-error.html.tmpl

diff --git a/CGI.pl b/CGI.pl
index de2d38085f8d65d11bdf863b065f47c0f520bad8..d16a9488378c5d7f069f022a7be269f08d96f68d 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -218,11 +218,13 @@ sub CheckFormField (\%$;\@) {
         SendSQL("SELECT description FROM fielddefs WHERE name=" . SqlQuote($fieldname));
         my $result = FetchOneColumn();
         if ($result) {
-            ThrowCodeError("A legal $result was not set.", undef, "abort");
+            $vars->{'field'} = $result;
         }
         else {
-            ThrowCodeError("A legal $fieldname was not set.", undef, "abort");
+            $vars->{'field'} = $fieldname;
         }
+        
+        ThrowCodeError("illegal_field", "abort");
       }
 }
 
@@ -233,9 +235,9 @@ sub CheckFormFieldDefined (\%$) {
        ) = @_;
 
     if (!defined $formRef->{$fieldname}) {
-          ThrowCodeError("$fieldname was not defined; " . 
-                                                    Param("browserbugmessage"));
-      }
+        $vars->{'field'} = $fieldname;  
+        ThrowCodeError("undefined_field");
+    }
 }
 
 sub BugAliasToID {
@@ -876,7 +878,7 @@ sub DisplayError {
 # For "this shouldn't happen"-type places in the code.
 # $vars->{'variables'} is a reference to a hash of useful debugging info.
 sub ThrowCodeError {
-  ($vars->{'error'}, $vars->{'variables'}, my $unlock_tables) = (@_);
+  ($vars->{'error'}, my $unlock_tables, $vars->{'variables'}) = (@_);
 
   SendSQL("UNLOCK TABLES") if $unlock_tables;
   
index 2b4859ccd26ae838b5182624db5e484cd955dfe2..9d3c0cca93cec8ff1a15b769130850c74512baf3 100755 (executable)
@@ -251,15 +251,14 @@ foreach my $b (grep(/^bit-\d*$/, keys %::FORM)) {
     if ($::FORM{$b}) {
         my $v = substr($b, 4);
         $v =~ /^(\d+)$/
-          || ThrowCodeError("One of the group bits submitted was invalid.",
-                                                                undef, "abort");
+          || ThrowCodeError("group_bit_invalid", "abort");
         if (!GroupIsActive($v)) {
             # Prevent the user from adding the bug to an inactive group.
             # Should only happen if there is a bug in Bugzilla or the user
             # hacked the "enter bug" form since otherwise the UI 
             # for adding the bug to the group won't appear on that form.
-            ThrowCodeError("Attempted to add bug to an inactive group, " . 
-                           "identified by the bit '$v'.", undef, "abort");
+            $vars->{'bit'} = $v;
+            ThrowCodeError("inactive_group", "abort");
         }
         $sql .= " + $v";    # Carefully written so that the math is
                             # done by MySQL, which can handle 64-bit math,
index c4a9af033aff34328109da892a6813529a604383..f1b074268d085614f70411988bd8d43ac54bbb79 100755 (executable)
@@ -805,9 +805,9 @@ SWITCH: for ($::FORM{'knob'}) {
 
         last SWITCH;
     };
-    # default
-    my $escaped_knob = html_quote($::FORM{'knob'});
-    ThrowCodeError("Unknown action $escaped_knob!\n");
+    
+    $vars->{'action'} = $::FORM{'knob'};
+    ThrowCodeError("unknown_action");
 }
 
 
index 64bf5064e3220a04cce812033c8a7d710f00126f..d731dbc494fcd75fa0bf5c0ae1a6c666d4dab009 100644 (file)
     to any [% parameters %] which you may have set before calling
     ThrowCodeError.
 
-  [% ELSIF error == "another_error_tag" %]
-    This is another sample error, without a special title. This 
-    should be the usual usage for this file. This sample can be removed.
+  [% ELSIF error == "group_bit_invalid" %]
+    One of the group bits submitted was invalid.
 
+  [% ELSIF error == "illegal_field" %]
+    A legal [% field FILTER html %] was not set.
+    
+  [% ELSIF error == "inactive_group" %]
+    Attempted to add bug to an inactive group, identified by the bit 
+    '[% bit FILTER html %]'.
+    
   [% ELSIF error == "template_error" %]
     [% template_error_msg %]
 
+  [% ELSIF error == "undefined_field" %]
+    [% field FILTER html %] was not defined; [% Param('browserbugmessage') %]
+
+  [% ELSIF error == "unknown_action" %]
+    Unknown action [% action FILTER html %]!
+    
   [% ELSE %]
     [%# Cope with legacy calling convention, where "error" was the string
       # to print.