[FIX] web: fix error stack undefined

In javascript, Error.stack is not standard so it could be undefined on
some browsers.

This commit fixes possible crashes when we perform some operations
on error.stack.

closes odoo/odoo#76917

X-original-commit: f8bc701e78b31f90a30baebe734290f6202a0af9
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Michael (mcm)
2021-09-27 16:56:15 +00:00
parent 3f2ffca97a
commit 1331165c0f
@@ -29,7 +29,7 @@ export function formatTraceback(error) {
// _onOpenFormView@http://localhost:8069/web/content/425-baf33f1/web.assets.js:1064:30
// ...
traceback = `${errorName}: ${error.message}\n${error.stack}`.replace(/\n/g, "\n ");
} else {
} else if (error.stack) {
// Chromium stack starts with the error's name but the name is "Error" by default
// so we replace it to have the error type name
traceback = error.stack.replace(/^[^:]*/g, errorName);