Bug 1214076 - allow TokenServerClient errors to be JSON.stringify'd. r=rnewman

This commit is contained in:
Mark Hammond 2015-10-15 08:57:31 +11:00
parent d0fb347fcf
commit f8d9dac2f5
2 changed files with 7 additions and 0 deletions

View File

@ -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);

View File

@ -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.