summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Error.pm
diff options
context:
space:
mode:
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;