Skip to content

Commit

Permalink
feat: add rescue function
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Sep 19, 2024
1 parent 42f7c8b commit b24bdb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions storage/framework/core/error-handling/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './handler'
export * from './utils'
export {
err,
errAsync,
Expand Down
7 changes: 7 additions & 0 deletions storage/framework/core/error-handling/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function rescue<T>(fn: () => T, fallback: T): T {
try {
return fn()
} catch {
return fallback
}
}

0 comments on commit b24bdb1

Please sign in to comment.