mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] *: use a custom error class for all errors thrown by owl
This commit makes all errors thrown in owl use a custom error class. The main point of this is to always wrap user-code errors that happen during the owl lifecycle so that they can be treated uniformly in onError by checking the cause property, and also allows user code to differenciate owl errors from non-owl errors reliably at runtime.
This commit is contained in:
committed by
Géry Debongnie
parent
30bc605c84
commit
7786077921
@@ -1,3 +1,4 @@
|
||||
import { OwlError } from "../../src/runtime/error_handling";
|
||||
import {
|
||||
App,
|
||||
Component,
|
||||
@@ -499,7 +500,7 @@ describe("Portal", () => {
|
||||
</div>`;
|
||||
state = { error: false };
|
||||
setup() {
|
||||
onError((e) => (error = e));
|
||||
onError(({ cause }) => (error = cause));
|
||||
}
|
||||
}
|
||||
addOutsideDiv(fixture);
|
||||
@@ -958,14 +959,15 @@ describe("Portal: Props validation", () => {
|
||||
</t>
|
||||
</div>`;
|
||||
}
|
||||
let error: Error;
|
||||
let error: OwlError;
|
||||
try {
|
||||
await mount(Parent, fixture, { dev: true });
|
||||
} catch (e) {
|
||||
error = e as Error;
|
||||
error = e as OwlError;
|
||||
}
|
||||
expect(error!).toBeDefined();
|
||||
expect(error!.message).toBe(`' ' is not a valid selector`);
|
||||
expect(error!.cause).toBeDefined();
|
||||
expect(error!.cause.message).toBe(`' ' is not a valid selector`);
|
||||
});
|
||||
|
||||
test("target must be a valid selector 2", async () => {
|
||||
|
||||
Reference in New Issue
Block a user