From a86ee3a1ca5213d5401c6425cfb0fcfc7bb15e78 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Tue, 31 Mar 2009 06:37:53 +0000 Subject: Bug 432907: Create a JSON frontend for WebServices Patch by Max Kanat-Alexander r=dkl, a=mkanat --- Bugzilla/Error.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'Bugzilla/Error.pm') 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; -- cgit v1.2.3-24-g4f1b