mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: do not shadow the initial error in some cases
Before this commit, the error handling code simply destroyed the application whenever an unhandled error occured in the owl rendering process. This is perfectly fine, except that since the application is potentially corrupted, the destroy code may crash as well. We simply catch those errors to avoid shadowing the main issue. closes #866
This commit is contained in:
@@ -586,4 +586,25 @@ describe("component error handling (catchError)", () => {
|
||||
await mount(Parent, { target: fixture });
|
||||
expect(fixture.innerHTML).toBe("<div>Error</div>");
|
||||
});
|
||||
|
||||
test("errors in mounted and in willUnmount", async () => {
|
||||
expect.assertions(1);
|
||||
class Example extends Component {
|
||||
static template = xml`<div/>`;
|
||||
val;
|
||||
mounted() {
|
||||
throw new Error("Error in mounted");
|
||||
this.val = { foo: "bar" };
|
||||
}
|
||||
willUnmount() {
|
||||
console.log(this.val.foo);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await mount(Example, { target: fixture });
|
||||
} catch (e) {
|
||||
expect(e.message).toBe("Error in mounted");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user