From ecf0f13ce883bf5b3a1db52372b437a04e8fed8d Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Thu, 20 May 2010 15:46:29 +0000 Subject: [PATCH] Bug 565879: Merge ThrowCodeError("action_unrecognized"), ThrowUserError("no_valid_action") and ThrowCodeError("unknown_action") r=ghendricks a=LpSolit git-svn-id: svn://10.0.0.236/trunk@260347 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/attachment.cgi | 2 +- mozilla/webtools/bugzilla/buglist.cgi | 2 +- mozilla/webtools/bugzilla/chart.cgi | 2 +- mozilla/webtools/bugzilla/editclassifications.cgi | 2 +- mozilla/webtools/bugzilla/editcomponents.cgi | 4 +--- mozilla/webtools/bugzilla/editfields.cgi | 2 +- mozilla/webtools/bugzilla/editflagtypes.cgi | 2 +- mozilla/webtools/bugzilla/editgroups.cgi | 7 +------ mozilla/webtools/bugzilla/editkeywords.cgi | 2 +- mozilla/webtools/bugzilla/editmilestones.cgi | 4 +--- mozilla/webtools/bugzilla/editproducts.cgi | 5 +---- mozilla/webtools/bugzilla/editusers.cgi | 3 +-- mozilla/webtools/bugzilla/editvalues.cgi | 7 +------ mozilla/webtools/bugzilla/editversions.cgi | 4 +--- mozilla/webtools/bugzilla/editworkflow.cgi | 2 +- mozilla/webtools/bugzilla/relogin.cgi | 2 +- mozilla/webtools/bugzilla/report.cgi | 2 +- .../en/default/global/code-error.html.tmpl | 15 +-------------- .../en/default/global/user-error.html.tmpl | 11 +++++++---- mozilla/webtools/bugzilla/token.cgi | 7 ++----- mozilla/webtools/bugzilla/votes.cgi | 2 +- 22 files changed, 29 insertions(+), 62 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index cac0fa4f71a..bec54cf6e35 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -7187 \ No newline at end of file +7188 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/attachment.cgi b/mozilla/webtools/bugzilla/attachment.cgi index b6515d037fa..b650a352274 100755 --- a/mozilla/webtools/bugzilla/attachment.cgi +++ b/mozilla/webtools/bugzilla/attachment.cgi @@ -127,7 +127,7 @@ elsif ($action eq "delete") { } else { - ThrowCodeError("unknown_action", { action => $action }); + ThrowUserError('unknown_action', {action => $action}); } exit; diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index 65eb6f380c8..8741f434f86 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/buglist.cgi @@ -511,7 +511,7 @@ elsif (($cmdtype eq "doit") && defined $cgi->param('remtype')) { # We add or remove bugs based on the action choosen. my $action = trim($cgi->param('action') || ''); $action =~ /^(add|remove)$/ - || ThrowCodeError('unknown_action', {'action' => $action}); + || ThrowUserError('unknown_action', {action => $action}); # If we are removing bugs, then we must have an existing # saved search selected. diff --git a/mozilla/webtools/bugzilla/chart.cgi b/mozilla/webtools/bugzilla/chart.cgi index 0b46347b5ea..dcd83cb01e6 100755 --- a/mozilla/webtools/bugzilla/chart.cgi +++ b/mozilla/webtools/bugzilla/chart.cgi @@ -227,7 +227,7 @@ elsif ($action eq "convert_search") { print $cgi->redirect(-location => correct_urlbase() . "query.cgi?format=create-series$url"); } else { - ThrowCodeError("unknown_action"); + ThrowUserError('unknown_action', {action => $action}); } exit; diff --git a/mozilla/webtools/bugzilla/editclassifications.cgi b/mozilla/webtools/bugzilla/editclassifications.cgi index 61b014c8d7d..db9dd7f0a87 100755 --- a/mozilla/webtools/bugzilla/editclassifications.cgi +++ b/mozilla/webtools/bugzilla/editclassifications.cgi @@ -233,4 +233,4 @@ if ($action eq 'reclassify') { # No valid action found # -ThrowCodeError("action_unrecognized", {action => $action}); +ThrowUserError('unknown_action', {action => $action}); diff --git a/mozilla/webtools/bugzilla/editcomponents.cgi b/mozilla/webtools/bugzilla/editcomponents.cgi index 70afd9c9ff2..fd30daed45f 100755 --- a/mozilla/webtools/bugzilla/editcomponents.cgi +++ b/mozilla/webtools/bugzilla/editcomponents.cgi @@ -252,7 +252,5 @@ if ($action eq 'update') { exit; } -# # No valid action found -# -ThrowUserError('no_valid_action', {'field' => "component"}); +ThrowUserError('unknown_action', {action => $action}); diff --git a/mozilla/webtools/bugzilla/editfields.cgi b/mozilla/webtools/bugzilla/editfields.cgi index 0f7a45fb781..e207a2ee43b 100755 --- a/mozilla/webtools/bugzilla/editfields.cgi +++ b/mozilla/webtools/bugzilla/editfields.cgi @@ -171,5 +171,5 @@ elsif ($action eq 'delete') { || ThrowTemplateError($template->error()); } else { - ThrowUserError('no_valid_action', {'field' => 'custom_field'}); + ThrowUserError('unknown_action', {action => $action}); } diff --git a/mozilla/webtools/bugzilla/editflagtypes.cgi b/mozilla/webtools/bugzilla/editflagtypes.cgi index d389c6db715..a0e64957b00 100755 --- a/mozilla/webtools/bugzilla/editflagtypes.cgi +++ b/mozilla/webtools/bugzilla/editflagtypes.cgi @@ -86,7 +86,7 @@ elsif ($action eq 'confirmdelete') { confirmDelete(); } elsif ($action eq 'delete') { deleteType($token); } elsif ($action eq 'deactivate') { deactivate($token); } else { - ThrowCodeError("action_unrecognized", { action => $action }); + ThrowUserError('unknown_action', {action => $action}); } exit; diff --git a/mozilla/webtools/bugzilla/editgroups.cgi b/mozilla/webtools/bugzilla/editgroups.cgi index 87a31816d14..a879aa7702e 100755 --- a/mozilla/webtools/bugzilla/editgroups.cgi +++ b/mozilla/webtools/bugzilla/editgroups.cgi @@ -357,13 +357,8 @@ if ($action eq 'remove_regexp') { exit; } - -# # No valid action found -# - -ThrowCodeError("action_unrecognized", $vars); - +ThrowUserError('unknown_action', {action => $action}); # Helper sub to handle the making of changes to a group sub doGroupChanges { diff --git a/mozilla/webtools/bugzilla/editkeywords.cgi b/mozilla/webtools/bugzilla/editkeywords.cgi index a9b46fef565..6c20dfd05d2 100755 --- a/mozilla/webtools/bugzilla/editkeywords.cgi +++ b/mozilla/webtools/bugzilla/editkeywords.cgi @@ -183,4 +183,4 @@ if ($action eq 'delete') { exit; } -ThrowCodeError("action_unrecognized", $vars); +ThrowUserError('unknown_action', {action => $action}); diff --git a/mozilla/webtools/bugzilla/editmilestones.cgi b/mozilla/webtools/bugzilla/editmilestones.cgi index ff13b61145c..ce622705efc 100755 --- a/mozilla/webtools/bugzilla/editmilestones.cgi +++ b/mozilla/webtools/bugzilla/editmilestones.cgi @@ -218,7 +218,5 @@ if ($action eq 'update') { exit; } -# # No valid action found -# -ThrowUserError('no_valid_action', {'field' => "target_milestone"}); +ThrowUserError('unknown_action', {action => $action}); diff --git a/mozilla/webtools/bugzilla/editproducts.cgi b/mozilla/webtools/bugzilla/editproducts.cgi index 4a302aa6cb6..6d5c5e59356 100755 --- a/mozilla/webtools/bugzilla/editproducts.cgi +++ b/mozilla/webtools/bugzilla/editproducts.cgi @@ -422,8 +422,5 @@ if ($action eq 'updategroupcontrols') { exit; } -# # No valid action found -# - -ThrowUserError('no_valid_action', {field => "product"}); +ThrowUserError('unknown_action', {action => $action}); diff --git a/mozilla/webtools/bugzilla/editusers.cgi b/mozilla/webtools/bugzilla/editusers.cgi index 1950446c7f7..f53fde98582 100755 --- a/mozilla/webtools/bugzilla/editusers.cgi +++ b/mozilla/webtools/bugzilla/editusers.cgi @@ -675,8 +675,7 @@ if ($action eq 'search') { ########################################################################### } else { - $vars->{'action'} = $action; - ThrowCodeError('action_unrecognized', $vars); + ThrowUserError('unknown_action', {action => $action}); } exit; diff --git a/mozilla/webtools/bugzilla/editvalues.cgi b/mozilla/webtools/bugzilla/editvalues.cgi index a9538523022..3f08a1671f5 100755 --- a/mozilla/webtools/bugzilla/editvalues.cgi +++ b/mozilla/webtools/bugzilla/editvalues.cgi @@ -193,10 +193,5 @@ if ($action eq 'update') { display_field_values($vars); } - -# # No valid action found -# -# We can't get here without $field being defined -- -# See the unless($field) block at the top. -ThrowUserError('no_valid_action', { field => $field } ); +ThrowUserError('unknown_action', {action => $action}); diff --git a/mozilla/webtools/bugzilla/editversions.cgi b/mozilla/webtools/bugzilla/editversions.cgi index b4cf9febc6f..0888ef0c643 100755 --- a/mozilla/webtools/bugzilla/editversions.cgi +++ b/mozilla/webtools/bugzilla/editversions.cgi @@ -219,7 +219,5 @@ if ($action eq 'update') { exit; } -# # No valid action found -# -ThrowUserError('no_valid_action', {'field' => "version"}); +ThrowUserError('unknown_action', {action => $action}); diff --git a/mozilla/webtools/bugzilla/editworkflow.cgi b/mozilla/webtools/bugzilla/editworkflow.cgi index 7e51798fc26..321f077fe5f 100755 --- a/mozilla/webtools/bugzilla/editworkflow.cgi +++ b/mozilla/webtools/bugzilla/editworkflow.cgi @@ -147,5 +147,5 @@ elsif ($action eq 'update_comment') { load_template('comment', 'workflow_updated'); } else { - ThrowCodeError("action_unrecognized", {action => $action}); + ThrowUserError('unknown_action', {action => $action}); } diff --git a/mozilla/webtools/bugzilla/relogin.cgi b/mozilla/webtools/bugzilla/relogin.cgi index 100fc2c7f16..7dcbde6250f 100755 --- a/mozilla/webtools/bugzilla/relogin.cgi +++ b/mozilla/webtools/bugzilla/relogin.cgi @@ -190,7 +190,7 @@ elsif ($action eq 'end-sudo') { # No valid action found else { Bugzilla->login(LOGIN_OPTIONAL); - ThrowCodeError('unknown_action', {action => $action}); + ThrowUserError('unknown_action', {action => $action}); } # Display the template diff --git a/mozilla/webtools/bugzilla/report.cgi b/mozilla/webtools/bugzilla/report.cgi index 4c9a98b8aa4..0537235fe78 100755 --- a/mozilla/webtools/bugzilla/report.cgi +++ b/mozilla/webtools/bugzilla/report.cgi @@ -289,7 +289,7 @@ elsif ($action eq "plot") { $vars->{'data'} = \@image_data; } else { - ThrowCodeError("unknown_action", {action => $cgi->param('action')}); + ThrowUserError('unknown_action', {action => $action}); } my $format = $template->get_format("reports/report", $formatparam, diff --git a/mozilla/webtools/bugzilla/template/en/default/global/code-error.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/global/code-error.html.tmpl index e3bd3ba8b0c..74365a80fa0 100644 --- a/mozilla/webtools/bugzilla/template/en/default/global/code-error.html.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/global/code-error.html.tmpl @@ -37,13 +37,7 @@ [% DEFAULT title = "Internal Error" %] [% error_message = BLOCK %] - [% IF error == "action_unrecognized" %] - [% docslinks = {'query.html' => "Searching for $terms.bugs", - 'query.html#list' => "$terms.Bug lists"} %] - I don't recognize the value ([% action FILTER html %]) - of the action variable. - - [% ELSIF error == "attachment_local_storage_disabled" %] + [% IF error == "attachment_local_storage_disabled" %] [% title = "Local Storage Disabled" %] You cannot store attachments locally. This feature is disabled. @@ -450,13 +444,6 @@ [% ELSIF error == "undefined_field" %] Form field [% field FILTER html %] was not defined. - [% ELSIF error == "unknown_action" %] - [% IF action %] - Unknown action [% action FILTER html %]! - [% ELSE %] - I could not figure out what you wanted to do. - [% END %] - [% ELSIF error == "unknown_method" %] The requested method '[% method FILTER html %]' was not found. diff --git a/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl index c5667bd27dd..1d599786103 100644 --- a/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl @@ -1251,10 +1251,6 @@ Either no products have been defined to enter [% terms.bugs %] against or you have not been given access to any. - [% ELSIF error == "no_valid_action" %] - [% title = "No valid action specified" %] - Cannot edit [% field_descs.$field FILTER html %]: no valid action was specified. - [% ELSIF error == "number_not_numeric" %] [% title = "Numeric Value Required" %] The value '[% num FILTER html %]' in the @@ -1581,6 +1577,13 @@ [% END %] token too recently to request another. Please wait a while and try again. + [% ELSIF error == "unknown_action" %] + [% IF action %] + Unknown action [% action FILTER html %]! + [% ELSE %] + I could not figure out what you wanted to do. + [% END %] + [% ELSIF error == "unknown_keyword" %] [% title = "Unknown Keyword" %] [% keyword FILTER html %] is not a known keyword. diff --git a/mozilla/webtools/bugzilla/token.cgi b/mozilla/webtools/bugzilla/token.cgi index d4298cde788..56093038562 100755 --- a/mozilla/webtools/bugzilla/token.cgi +++ b/mozilla/webtools/bugzilla/token.cgi @@ -56,7 +56,7 @@ Bugzilla->login(LOGIN_OPTIONAL); # Throw an error if the form does not contain an "action" field specifying # what the user wants to do. -$action || ThrowCodeError("unknown_action"); +$action || ThrowUserError('unknown_action'); # If a token was submitted, make sure it is a valid token that exists in the # database and is the correct type for the action being taken. @@ -163,10 +163,7 @@ if ($action eq 'reqpw') { } elsif ($action eq 'cancel_new_account') { cancel_create_account($token); } else { - # If the action that the user wants to take (specified in the "a" form field) - # is none of the above listed actions, display an error telling the user - # that we do not understand what they would like to do. - ThrowCodeError("unknown_action", { action => $action }); + ThrowUserError('unknown_action', {action => $action}); } exit; diff --git a/mozilla/webtools/bugzilla/votes.cgi b/mozilla/webtools/bugzilla/votes.cgi index b7622fbb04c..04589d4bca4 100755 --- a/mozilla/webtools/bugzilla/votes.cgi +++ b/mozilla/webtools/bugzilla/votes.cgi @@ -41,7 +41,7 @@ elsif ($action eq "show_user" or $action eq 'vote') { $cgi->param('id', 'voting/user.html'); } else { - ThrowCodeError("unknown_action", {action => $action}); + ThrowUserError('unknown_action', {action => $action}); } print $cgi->redirect('page.cgi?' . $cgi->query_string);