зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1698554 - [devtools] Improve error logging when a request fails with a custom exception. r=nchevobbe
Like BrowsingContextTargetActor.detach which was throwing { error: wrongState } and we were logging "(void 0)" because error.message was undefined, while error was the thrown JS object. Differential Revision: https://phabricator.services.mozilla.com/D107986
This commit is contained in:
Родитель
61d6f12836
Коммит
71dcc33581
|
@ -81,6 +81,14 @@ add_task(async function test_protocoljs_actor() {
|
|||
`\\(${TEST_ERRORS_ACTOR_URL}:\\d+:\\d+\\)`
|
||||
).test(e.message);
|
||||
});
|
||||
await Assert.rejects(testErrorsFront.throwsString(), e => {
|
||||
return new RegExp(`ErrorString from: ${testErrorsFront.actorID}`).test(
|
||||
e.message
|
||||
);
|
||||
});
|
||||
await Assert.rejects(testErrorsFront.throwsObject(), e => {
|
||||
return new RegExp(`foo from: ${testErrorsFront.actorID}`).test(e.message);
|
||||
});
|
||||
|
||||
await gClient.close();
|
||||
});
|
||||
|
|
|
@ -22,6 +22,14 @@ const testErrorsSpec = protocol.generateActorSpec({
|
|||
request: {},
|
||||
response: {},
|
||||
},
|
||||
throwsString: {
|
||||
request: {},
|
||||
response: {},
|
||||
},
|
||||
throwsObject: {
|
||||
request: {},
|
||||
response: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -31,17 +39,29 @@ const TestErrorsActor = protocol.ActorClassWithSpec(testErrorsSpec, {
|
|||
this.conn = conn;
|
||||
},
|
||||
|
||||
throwsComponentsException: async function() {
|
||||
throwsComponentsException() {
|
||||
throw components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
|
||||
},
|
||||
|
||||
throwsException: async function() {
|
||||
throwsException() {
|
||||
return this.a.b.c;
|
||||
},
|
||||
|
||||
throwsJSError: async function() {
|
||||
throwsJSError() {
|
||||
throw new Error("JSError");
|
||||
},
|
||||
|
||||
throwsString() {
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw "ErrorString";
|
||||
},
|
||||
|
||||
throwsObject() {
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw {
|
||||
error: "foo",
|
||||
};
|
||||
},
|
||||
});
|
||||
exports.TestErrorsActor = TestErrorsActor;
|
||||
|
||||
|
|
|
@ -94,10 +94,12 @@ class Actor extends Pool {
|
|||
writeError(error, typeName, method) {
|
||||
console.error(
|
||||
`Error while calling actor '${typeName}'s method '${method}'`,
|
||||
error.message
|
||||
error.message || error
|
||||
);
|
||||
// Also log the error object as-is in order to log the server side stack
|
||||
// nicely in the console, while the previous log will log the client side stack only.
|
||||
if (error.stack) {
|
||||
console.error(error.stack);
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
// Do not try to send the error if the actor is destroyed
|
||||
|
@ -110,7 +112,11 @@ class Actor extends Pool {
|
|||
from: this.actorID,
|
||||
// error.error -> errors created using the throwError() helper
|
||||
// error.name -> errors created using `new Error` or Components.exception
|
||||
error: error.error || error.name || "unknownError",
|
||||
// typeof(error)=="string" -> a method thrown like this `throw "a string"`
|
||||
error:
|
||||
error.error ||
|
||||
error.name ||
|
||||
(typeof error == "string" ? error : "unknownError"),
|
||||
message: error.message,
|
||||
// error.fileName -> regular Error instances
|
||||
// error.filename -> errors created using Components.exception
|
||||
|
|
Загрузка…
Ссылка в новой задаче