diff --git a/addons/web/static/src/js/core/error_utils.js b/addons/web/static/src/js/core/error_utils.js index 2ccfb5cd6db..1c3e14fa01c 100644 --- a/addons/web/static/src/js/core/error_utils.js +++ b/addons/web/static/src/js/core/error_utils.js @@ -37,6 +37,14 @@ export function formatTraceback(error) { export async function annotateTraceback(error) { const traceback = formatTraceback(error); await loadJS('/web/static/lib/stacktracejs/stacktrace.js'); + // In Firefox, the error stack generated by anonymous code (example: invalid + // code in a template) is not compatible with the stacktrace lib. This code + // corrects the stack to make it compatible with the lib stacktrace. + if (error.stack) { + const regex = / line (\d*) > (Function):(\d*)/gm; + const subst = `:$1`; + error.stack = error.stack.replace(regex, subst); + } const frames = await StackTrace.fromError(error); const lines = traceback.split('\n'); if (lines[lines.length-1].trim() === "") {