[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:
Géry Debongnie
2021-07-03 15:34:20 +02:00
committed by aab-odoo
parent a6bb4d8ee1
commit 3a93370ab6
2 changed files with 29 additions and 1 deletions
+21
View File
@@ -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");
}
});
});