vasille
Version:
The same framework which is designed to build bulletproof frontends (core library).
24 lines (23 loc) • 576 B
JavaScript
export let reportError = (e) => {
console.error(e);
console.log("Docs Link https://github.com/vasille-js/vasille-js/blob/v4/doc/V4-API.md");
};
export function setErrorHandler(handler) {
reportError = handler;
}
export function safe(fn) {
return ((...args) => {
try {
const result = fn(...args);
if (result instanceof Promise) {
result.catch(reportError);
}
else {
return result;
}
}
catch (e) {
reportError(e);
}
});
}