Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
e0db56e7
Commit
e0db56e7
authored
May 28, 2008
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 435507: Provide a method of hooking the WebService error codes
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=ghendricks, a=mkanat
parent
993a1c53
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
2 deletions
+65
-2
Error.pm
Bugzilla/Error.pm
+6
-1
Hook.pm
Bugzilla/Hook.pm
+19
-0
webservice-error_codes.pl
extensions/example/code/webservice-error_codes.pl
+25
-0
WSExample.pm
extensions/example/lib/WSExample.pm
+3
-1
user-error-errors.html.tmpl
...ns/example/template/en/global/user-error-errors.html.tmpl
+12
-0
No files found.
Bugzilla/Error.pm
View file @
e0db56e7
...
...
@@ -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
;
...
...
Bugzilla/Hook.pm
View file @
e0db56e7
...
...
@@ -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
extensions/example/code/webservice-error_codes.pl
0 → 100644
View file @
e0db56e7
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Everything Solved, Inc.
# Portions created by Everything Solved, Inc. are Copyright (C) 2008
# Everything Solved, Inc. All Rights Reserved.
#
# Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org>
use
strict
;
use
warnings
;
use
Bugzilla
;
my
$error_map
=
Bugzilla
->
hook_args
->
{
error_map
};
$error_map
->
{
'example_my_error'
}
=
10001
;
extensions/example/lib/WSExample.pm
View file @
e0db56e7
...
...
@@ -21,10 +21,12 @@
package
extensions::example::lib::
WSExample
;
use
strict
;
use
warnings
;
use
base
qw(Bugzilla::WebService)
;
use
Bugzilla::
Error
;
# This can be called as Example.hello() from XML-RPC.
sub
hello
{
return
'Hello!'
;
}
sub
throw_an_error
{
ThrowUserError
(
'example_my_error'
)
}
1
;
extensions/example/template/en/global/user-error-errors.html.tmpl
0 → 100644
View file @
e0db56e7
[%# Note that error messages should generally be indented four spaces, like
# below, because when Bugzilla translates an error message into plain
# text, it takes four spaces off the beginning of the lines.
#
# Note also that I prefixed my error name with "example", the name of my
# extension, so that I wouldn't conflict with other error names in
# Bugzilla or other extensions.
#%]
[% IF error == "example_my_error" %]
[% title = "Example Error Title" %]
This is the error message! It contains <em>some html</em>.
[% END %]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment