Skip to content

Commit b24bdb1

Browse files
committed
feat: add rescue function
1 parent 42f7c8b commit b24bdb1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

storage/framework/core/error-handling/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './handler'
2+
export * from './utils'
23
export {
34
err,
45
errAsync,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function rescue<T>(fn: () => T, fallback: T): T {
2+
try {
3+
return fn()
4+
} catch {
5+
return fallback
6+
}
7+
}

0 commit comments

Comments
 (0)