mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1214076 - allow TokenServerClient errors to be JSON.stringify'd. r=rnewman
This commit is contained in:
parent
d0fb347fcf
commit
f8d9dac2f5
@ -100,6 +100,8 @@ add_test(function test_conditions_required_response_handling() {
|
||||
function onResponse(error, token) {
|
||||
do_check_true(error instanceof TokenServerClientServerError);
|
||||
do_check_eq(error.cause, "conditions-required");
|
||||
// Check a JSON.stringify works on our errors as our logging will try and use it.
|
||||
do_check_true(JSON.stringify(error), "JSON.stringify worked");
|
||||
do_check_null(token);
|
||||
|
||||
do_check_eq(error.urls.tos, tosURL);
|
||||
|
@ -44,6 +44,11 @@ TokenServerClientError.prototype._toStringFields = function() {
|
||||
TokenServerClientError.prototype.toString = function() {
|
||||
return this.name + "(" + JSON.stringify(this._toStringFields()) + ")";
|
||||
}
|
||||
TokenServerClientError.prototype.toJSON = function() {
|
||||
let result = this._toStringFields();
|
||||
result["name"] = this.name;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a TokenServerClient error that occurred in the network layer.
|
||||
|
Loading…
Reference in New Issue
Block a user