build(utils): build26 from 45504a2b

This commit is contained in:
publish
2026-08-05 18:57:34 +02:00
commit 9fed1b6ef2
236 changed files with 2331 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
//#region src/function/try-catch.ts
/**
* Wrap a function to catch and handle errors instead of throwing.
*
* @example
* ```ts
* const safeFn = tryCatch(riskyFn, (e) => logger.error(e));
* safeFn?.(); // Never throws
* ```
*/
function tryCatch(fn, onError = console.error) {
if (!fn) return void 0;
return ((...args) => {
try {
return fn(...args);
} catch (error) {
onError(error);
return;
}
});
}
//#endregion
export { tryCatch };
//# sourceMappingURL=try-catch.js.map