[FIX] web: avoid masking crashes when original error has no stack

In some contexts, an error caught by the error service has no stack,
trying to annotate the stacktrace of this error with the Stacktrace
library crashes, masking the original error which is unwanted.

closes odoo/odoo#77421

X-original-commit: 347ddcc06e23d8f1a94c06379b2bfe104b116d90
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Samuel Degueldre
2021-09-30 17:11:50 +00:00
parent 985b7f37d7
commit 27853412a3
@@ -64,7 +64,14 @@ export async function annotateTraceback(error) {
error.stack = error.stack.replace(regex, subst);
}
// eslint-disable-next-line no-undef
const frames = await StackTrace.fromError(error);
let frames;
try {
frames = await StackTrace.fromError(error);
} catch (e) {
// This can crash if the originalError has no stack/stacktrace property
console.warn("The following error could not be annotated:", error, e);
return traceback;
}
const lines = traceback.split("\n");
if (lines[lines.length - 1].trim() === "") {
// firefox traceback have an empty line at the end