mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] component: improve errors when thrown from lifecycle hooks
Previously, a crash in a lifecycle hook for any reason would throw an error whose stack trace started from the scheduler and contained only the place where the hook was called by owl, but not the place where the hook was registered by the user. This proved very difficult for users to debug as they cannot really tell which component registered that hook. This commit alleviates the issue by creating a new Error when the hook is originally called, and wrapping the registered callback in a try catch, throwing an error with the correct stack trace instead of the error in the hook, and setting the error in the hook as the cause of this synthetic error.
This commit is contained in:
committed by
Géry Debongnie
parent
4a922ed82d
commit
804ad3c35e
@@ -1092,6 +1092,19 @@ exports[`errors and promises an error in mounted call will reject the mount prom
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`errors and promises an error in onMounted callback will have the component's setup in its stack trace 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div>abc</div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`errors and promises an error in patched call will reject the render promise 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user