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
2f34ebff
Commit
2f34ebff
authored
Feb 22, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 547126: Make the JSON-RPC return error codes that are numerically
identical to the XML-RPC error codes. r=dkl, a=mkanat
parent
c893bcf5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
5 deletions
+52
-5
JSONRPC.pm
Bugzilla/WebService/Server/JSONRPC.pm
+52
-5
No files found.
Bugzilla/WebService/Server/JSONRPC.pm
View file @
2f34ebff
...
...
@@ -85,6 +85,43 @@ sub datetime_format {
return
$iso_datetime
;
}
# Make all error messages returned by JSON::RPC go into the 100000
# range, and bring down all our errors into the normal range.
sub
_error
{
my
(
$self
,
$id
,
$code
)
=
(
shift
,
shift
,
shift
);
# All JSON::RPC errors are less than 1000.
if
(
$code
<
1000
)
{
$code
+=
100000
;
}
# Bugzilla::Error adds 100,000 to all *our* errors, so
# we know they came from us.
elsif
(
$code
>
100000
)
{
$code
-=
100000
;
}
# We can't just set $_[1] because it's not always settable,
# in JSON::RPC::Server.
unshift
(
@_
,
$id
,
$code
);
my
$json
=
$self
->
SUPER::
_error
(
@_
);
# We want to always send the JSON-RPC 1.1 error format, although
# If we're not in JSON-RPC 1.1, we don't need the silly "name" parameter.
if
(
!
$self
->
version
)
{
my
$object
=
$self
->
json
->
decode
(
$json
);
my
$message
=
$object
->
{
error
};
# Just assure that future versions of JSON::RPC don't change the
# JSON-RPC 1.0 error format.
if
(
!
ref
$message
)
{
$object
->
{
error
}
=
{
code
=>
$code
,
message
=>
$message
,
};
$json
=
$self
->
json
->
encode
(
$object
);
}
}
return
$json
;
}
##################
# Login Handling #
##################
...
...
@@ -254,12 +291,22 @@ All other types are standard JSON types.
=head1 ERRORS
All errors thrown by Bugzilla itself have 100000 added to their numeric
code. So, if the documentation says that an error is C<302>, then
it will be C<100302> when it is thrown via JSON-RPC.
JSON-RPC 1.0 and JSON-RPC 1.1 both return an C<error> element when they
throw an error. In Bugzilla, the error contents look like:
{ message: 'Some message here', code: 123 }
So, for example, in JSON-RPC 1.0, an error response would look like:
{
result: null,
error: { message: 'Some message here', code: 123 },
id: 1
}
Errors less than 100000 are errors thrown by the JSON-RPC library that
Bugzilla uses, not by Bugzilla.
Every error has a "code", as described in L<Bugzilla::WebService/ERRORS>.
Errors with a numeric C<code> higher than 100000 are errors thrown by
the JSON-RPC library that Bugzilla uses, not by Bugzilla.
=head1 SEE ALSO
...
...
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