Bug 1919785 - [devtools] Improve error logging when an exception is thrown in devtools workers. r=devtools-reviewers,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D222790
This commit is contained in:
Alexandre Poirot 2024-09-30 12:04:31 +00:00
parent 0b0d5e673d
commit 5ddce9f95d
5 changed files with 25 additions and 5 deletions

View File

@ -41394,7 +41394,9 @@ Please specify the "importAttributesKeyword" generator option, whose value can b
// string.
return {
error: true,
message: error.message,
message:
error.message +
(error.stack ? "\nStack in the worker:" + error.stack : ""),
metadata: error.metadata,
};
}

View File

@ -3712,7 +3712,9 @@
// string.
return {
error: true,
message: error.message,
message:
error.message +
(error.stack ? "\nStack in the worker:" + error.stack : ""),
metadata: error.metadata,
};
}

View File

@ -372,7 +372,9 @@
// string.
return {
error: true,
message: error.message,
message:
error.message +
(error.stack ? "\nStack in the worker:" + error.stack : ""),
metadata: error.metadata,
};
}

View File

@ -158,6 +158,18 @@ add_task(async function testBaseURLErrorHandling() {
await gSourceMapLoader.getOriginalURLs(source);
ok(false, "Should throw");
} catch (e) {
is(e.message, "URL constructor: http:://example.com/ is not a valid URL.");
// We have to use startsWith as the rest of the message will be the stack trace in the worker thread
ok(
e.message.startsWith(
"URL constructor: http:://example.com/ is not a valid URL."
),
"the worker thrown with the right error message"
);
ok(
e.message.includes(
"getOriginalURLs@resource://devtools/client/shared/source-map-loader/source-map.js"
),
"Found at least one frame of the stack"
);
}
});

View File

@ -136,7 +136,9 @@ function asErrorMessage(error) {
// string.
return {
error: true,
message: error.message,
message:
error.message +
(error.stack ? "\nStack in the worker:" + error.stack : ""),
metadata: error.metadata,
};
}