summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Error.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Error.pm')
-rw-r--r--Bugzilla/Error.pm15
1 files changed, 8 insertions, 7 deletions
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm
index ef6320d15..e730022db 100644
--- a/Bugzilla/Error.pm
+++ b/Bugzilla/Error.pm
@@ -123,19 +123,13 @@ sub _throw_error {
if (Bugzilla->error_mode == ERROR_MODE_DIE_SOAP_FAULT) {
die SOAP::Fault->faultcode($code)->faultstring($message);
}
- else {
+ elsif (Bugzilla->error_mode == ERROR_MODE_JSON_RPC) {
my $server = Bugzilla->_json_server;
- my $status_code = 0;
- if (Bugzilla->error_mode == ERROR_MODE_REST) {
- my %status_code_map = %{ REST_STATUS_CODE_MAP() };
- $status_code = $status_code_map{$code} || $status_code_map{'_default'};
- }
# Technically JSON-RPC isn't allowed to have error numbers
# higher than 999, but we do this to avoid conflicts with
# the internal JSON::RPC error codes.
$server->raise_error(code => 100000 + $code,
- status_code => $status_code,
message => $message,
id => $server->{_bz_request_id},
version => $server->version);
@@ -146,6 +140,13 @@ sub _throw_error {
die if _in_eval();
$server->response($server->error_response_header);
}
+ else {
+ my $server = Bugzilla->api_server;
+ my %status_code_map = %{ $server->constants->{REST_STATUS_CODE_MAP} };
+ my $status_code = $status_code_map{$code} || $status_code_map{'_default'};
+ $server->return_error($status_code, $message, $code);
+ $server->response;
+ }
}
exit;
}