Skip to content

Commit

Permalink
feat: add safeCall utility function for error handling in async opera…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
chimpdev committed Jan 3, 2025
1 parent c8647ec commit 0dee200
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/utils/safeCall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
async function safeCall<T>(fn: () => Promise<T>): Promise<T | null> {
try {
return await fn();
} catch {
return null;
}
}

export default safeCall;

0 comments on commit 0dee200

Please # to comment.