diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Error.pm | 7 | ||||
-rw-r--r-- | Bugzilla/Hook.pm | 19 |
2 files changed, 25 insertions, 1 deletions
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm index 3e5688e2a..d15336a81 100644 --- a/Bugzilla/Error.pm +++ b/Bugzilla/Error.pm @@ -102,7 +102,12 @@ sub _throw_error { die("$message\n"); } elsif (Bugzilla->error_mode == ERROR_MODE_DIE_SOAP_FAULT) { - my $code = WS_ERROR_CODE->{$error}; + # Clone the hash so we aren't modifying the constant. + my %error_map = %{ WS_ERROR_CODE() }; + require Bugzilla::Hook; + Bugzilla::Hook::process('webservice-error_codes', + { error_map => \%error_map }); + my $code = $error_map{$error}; if (!$code) { $code = ERROR_UNKNOWN_FATAL if $name =~ /code/i; $code = ERROR_UNKNOWN_TRANSIENT if $name =~ /user/i; diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index 0cf566db1..820693ee0 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -262,3 +262,22 @@ WebService functions (and so that you also don't conflict with other plugins). =back + +=head2 webservice-error_codes + +If your webservice extension throws custom errors, you can set numeric +codes for those errors here. + +Extensions should use error codes above 10000, unless they are re-using +an already-existing error code. + +Params: + +=over + +=item C<error_map> + +A hash that maps the names of errors (like C<invalid_param>) to numbers. +See L<Bugzilla::WebService::Constants/WS_ERROR_CODE> for an example. + +=back |