diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2013-07-12 16:39:50 -0400 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-07-12 16:39:50 -0400 |
commit | 384d1d254d14bafc3fdf62a08668c6cb36249563 (patch) | |
tree | 4d4845fb43d9f3a85ee8cdb5c97afcb8aa7dff8a /Bugzilla/Error.pm | |
parent | 8a2ac0569e86483b6825d8b71bca4adbac345a1c (diff) | |
download | bugs-384d1d254d14bafc3fdf62a08668c6cb36249563.tar bugs-384d1d254d14bafc3fdf62a08668c6cb36249563.tar.gz bugs-384d1d254d14bafc3fdf62a08668c6cb36249563.tar.bz2 bugs-384d1d254d14bafc3fdf62a08668c6cb36249563.tar.xz bugs-384d1d254d14bafc3fdf62a08668c6cb36249563.zip |
Bug 866927 - Enhance Bugzilla WebServices to allow data access using REST
r=glob,a=justdave
Diffstat (limited to 'Bugzilla/Error.pm')
-rw-r--r-- | Bugzilla/Error.pm | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm index d64219e87..ee84183b1 100644 --- a/Bugzilla/Error.pm +++ b/Bugzilla/Error.pm @@ -104,7 +104,8 @@ sub _throw_error { die("$message\n"); } elsif (Bugzilla->error_mode == ERROR_MODE_DIE_SOAP_FAULT - || Bugzilla->error_mode == ERROR_MODE_JSON_RPC) + || Bugzilla->error_mode == ERROR_MODE_JSON_RPC + || Bugzilla->error_mode == ERROR_MODE_REST) { # Clone the hash so we aren't modifying the constant. my %error_map = %{ WS_ERROR_CODE() }; @@ -121,13 +122,20 @@ sub _throw_error { } else { 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, - message => $message, - id => $server->{_bz_request_id}, - version => $server->version); + $server->raise_error(code => 100000 + $code, + status_code => $status_code, + message => $message, + id => $server->{_bz_request_id}, + version => $server->version); # Most JSON-RPC Throw*Error calls happen within an eval inside # of JSON::RPC. So, in that circumstance, instead of exiting, # we die with no message. JSON::RPC checks raise_error before |