summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Error.pm
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-07-12 22:39:50 +0200
committerDave Lawrence <dlawrence@mozilla.com>2013-07-12 22:39:50 +0200
commit384d1d254d14bafc3fdf62a08668c6cb36249563 (patch)
tree4d4845fb43d9f3a85ee8cdb5c97afcb8aa7dff8a /Bugzilla/Error.pm
parent8a2ac0569e86483b6825d8b71bca4adbac345a1c (diff)
downloadbugzilla-384d1d254d14bafc3fdf62a08668c6cb36249563.tar.gz
bugzilla-384d1d254d14bafc3fdf62a08668c6cb36249563.tar.xz
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.pm18
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