[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:
Samuel Degueldre
2022-09-08 13:56:35 +02:00
committed by Géry Debongnie
parent a5a6a592c1
commit cfdf7caa50
14 changed files with 324 additions and 303 deletions
+6 -3
View File
@@ -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<