From 2a6f7d4663dfc5cb00c1bb8b8d8139869a22d461 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Mon, 12 Nov 2012 18:46:48 +0100 Subject: Bug 676844: Replace ThrowCodeError() by ThrowUserError() when the error is not triggered by the code itself r=glob a=LpSolit --- Bugzilla/Attachment.pm | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'Bugzilla/Attachment.pm') diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 1c524c24b..982435a3a 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -756,7 +756,7 @@ sub validate_obsolete { $vars->{'attach_id'} = $attachid; detaint_natural($attachid) - || ThrowCodeError('invalid_attach_id_to_obsolete', $vars); + || ThrowUserError('invalid_attach_id', $vars); # Make sure the attachment exists in the database. my $attachment = new Bugzilla::Attachment($attachid) @@ -771,7 +771,7 @@ sub validate_obsolete { if ($attachment->bug_id != $bug->bug_id) { $vars->{'my_bug_id'} = $bug->bug_id; $vars->{'attach_bug_id'} = $attachment->bug_id; - ThrowCodeError('mismatched_bug_ids_on_obsolete', $vars); + ThrowUserError('mismatched_bug_ids_on_obsolete', $vars); } next if $attachment->isobsolete; @@ -879,7 +879,7 @@ sub run_create_validators { $params->{creation_ts} ||= Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); $params->{modification_time} = $params->{creation_ts}; - $params->{submitter_id} = Bugzilla->user->id || ThrowCodeError('invalid_user'); + $params->{submitter_id} = Bugzilla->user->id || ThrowUserError('invalid_user'); return $params; } @@ -962,10 +962,18 @@ sub get_content_type { return 'text/plain' if ($cgi->param('ispatch') || $cgi->param('attach_text')); my $content_type; - if (!defined $cgi->param('contenttypemethod')) { - ThrowUserError("missing_content_type_method"); + my $method = $cgi->param('contenttypemethod') || ''; + + if ($method eq 'list') { + # The user selected a content type from the list, so use their + # selection. + $content_type = $cgi->param('contenttypeselection'); } - elsif ($cgi->param('contenttypemethod') eq 'autodetect') { + elsif ($method eq 'manual') { + # The user entered a content type manually, so use their entry. + $content_type = $cgi->param('contenttypeentry'); + } + else { defined $cgi->upload('data') || ThrowUserError('file_not_specified'); # The user asked us to auto-detect the content type, so use the type # specified in the HTTP request headers. @@ -979,19 +987,6 @@ sub get_content_type { $content_type = 'image/png'; } } - elsif ($cgi->param('contenttypemethod') eq 'list') { - # The user selected a content type from the list, so use their - # selection. - $content_type = $cgi->param('contenttypeselection'); - } - elsif ($cgi->param('contenttypemethod') eq 'manual') { - # The user entered a content type manually, so use their entry. - $content_type = $cgi->param('contenttypeentry'); - } - else { - ThrowCodeError("illegal_content_type_method", - { contenttypemethod => $cgi->param('contenttypemethod') }); - } return $content_type; } -- cgit v1.2.3-24-g4f1b