mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] app: rethrow errors that were not handled
This commit makes it so that when an error occurs in an owl app and none of the registered error handlers are able to handle it, we rethrow the error instead of just logging it to the console and swallowing it. This allows users of owl to handle errors that happen in owl applications by using event listeners for error and unhandledrejection events on the window.
This commit is contained in:
committed by
Géry Debongnie
parent
a5a6a592c1
commit
cfdf7caa50
+6
-3
@@ -6,6 +6,7 @@ import { Scheduler } from "./scheduler";
|
||||
import { validateProps } from "./template_helpers";
|
||||
import { TemplateSet, TemplateSetConfig } from "./template_set";
|
||||
import { validateTarget } from "./utils";
|
||||
import { handleError } from "./error_handling";
|
||||
|
||||
// reimplement dev mode stuff see last change in 0f7a8289a6fb8387c3c1af41c6664b2a8448758f
|
||||
|
||||
@@ -94,9 +95,7 @@ export class App<
|
||||
nodeErrorHandlers.set(node, handlers);
|
||||
}
|
||||
handlers.unshift((e) => {
|
||||
if (isResolved) {
|
||||
console.error(e);
|
||||
} else {
|
||||
if (!isResolved) {
|
||||
reject(e);
|
||||
}
|
||||
throw e;
|
||||
@@ -169,6 +168,10 @@ export class App<
|
||||
return node;
|
||||
};
|
||||
}
|
||||
|
||||
handleError(...args: Parameters<typeof handleError>) {
|
||||
return handleError(...args);
|
||||
}
|
||||
}
|
||||
|
||||
export async function mount<
|
||||
|
||||
Reference in New Issue
Block a user