diff options
author | David Lawrence <dkl@mozilla.com> | 2015-04-08 19:48:36 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2015-04-08 19:48:36 +0200 |
commit | dbfd6207290d1eee53fddec4c7c3b4aac0b2d47a (patch) | |
tree | aa190d8cc9e2b313dd7e85bf763c1bfe5502b75d /Bugzilla/Error.pm | |
parent | e6d2fb75aa3c183323c534a214f3dd9be5638676 (diff) | |
download | bugzilla-dbfd6207290d1eee53fddec4c7c3b4aac0b2d47a.tar.gz bugzilla-dbfd6207290d1eee53fddec4c7c3b4aac0b2d47a.tar.xz |
Bug 1051056: The REST API needs to be versioned so that new changes can be made that do not break compatibility
r=dylan,a=glob
Diffstat (limited to 'Bugzilla/Error.pm')
-rw-r--r-- | Bugzilla/Error.pm | 15 |
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; } |