mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] component: re-introduce error handling in lifecycle
This commit is contained in:
committed by
Aaron Bohy
parent
bca6afeb90
commit
e0c0306acd
@@ -1,4 +1,5 @@
|
||||
import { getCurrent } from "./component_node";
|
||||
import { nodeErrorHandlers } from "./error_handling";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// hooks
|
||||
@@ -47,3 +48,15 @@ export function onRender(fn: () => void | any) {
|
||||
return renderFn();
|
||||
};
|
||||
}
|
||||
|
||||
export function onError(fn: (error: Error) => void | any) {
|
||||
const node = getCurrent()!;
|
||||
let handlers = nodeErrorHandlers.get(node);
|
||||
if (handlers) {
|
||||
handlers.push(fn);
|
||||
} else {
|
||||
handlers = [];
|
||||
handlers.push(fn);
|
||||
nodeErrorHandlers.set(node, handlers);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user