@kellanjs/actioncraft
Version:
Fluent, type-safe builder for Next.js server actions.
20 lines • 549 B
JavaScript
/**
* Executes a callback function safely.
* Any error thrown by the callback is caught and logged (if a logFn is supplied)
* so that it never interrupts the main action flow.
*/
export async function safeExecuteCallback(callback, callbackName,
// Logger accepts (level, message, details?)
logFn) {
if (!callback)
return;
try {
await callback();
}
catch (error) {
if (logFn) {
logFn("error", `Error in ${callbackName} callback`, error);
}
}
}
//# sourceMappingURL=callbacks.js.map