summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Error.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-03-31 08:37:53 +0200
committermkanat%bugzilla.org <>2009-03-31 08:37:53 +0200
commita86ee3a1ca5213d5401c6425cfb0fcfc7bb15e78 (patch)
tree55ad97e67fa4322482f346289c113d211629338a /Bugzilla/Error.pm
parent470f355df99acba2855b97619897d650e8dd09e0 (diff)
downloadbugzilla-a86ee3a1ca5213d5401c6425cfb0fcfc7bb15e78.tar.gz
bugzilla-a86ee3a1ca5213d5401c6425cfb0fcfc7bb15e78.tar.xz
Bug 432907: Create a JSON frontend for WebServices
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat
Diffstat (limited to 'Bugzilla/Error.pm')
-rw-r--r--Bugzilla/Error.pm18
1 files changed, 16 insertions, 2 deletions
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm
index d15336a81..661c72f74 100644
--- a/Bugzilla/Error.pm
+++ b/Bugzilla/Error.pm
@@ -101,7 +101,9 @@ sub _throw_error {
if (Bugzilla->error_mode == ERROR_MODE_DIE) {
die("$message\n");
}
- elsif (Bugzilla->error_mode == ERROR_MODE_DIE_SOAP_FAULT) {
+ elsif (Bugzilla->error_mode == ERROR_MODE_DIE_SOAP_FAULT
+ || Bugzilla->error_mode == ERROR_MODE_JSON_RPC)
+ {
# Clone the hash so we aren't modifying the constant.
my %error_map = %{ WS_ERROR_CODE() };
require Bugzilla::Hook;
@@ -112,7 +114,19 @@ sub _throw_error {
$code = ERROR_UNKNOWN_FATAL if $name =~ /code/i;
$code = ERROR_UNKNOWN_TRANSIENT if $name =~ /user/i;
}
- die SOAP::Fault->faultcode($code)->faultstring($message);
+
+ if (Bugzilla->error_mode == ERROR_MODE_DIE_SOAP_FAULT) {
+ die SOAP::Fault->faultcode($code)->faultstring($message);
+ }
+ else {
+ my $server = Bugzilla->_json_server;
+ # 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);
+ $server->response($server->error_response_header);
+ }
}
}
exit;