Skip to content

Commit c4183a6

Browse files
committed
use normal try catch
1 parent ebea534 commit c4183a6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/sql-sqlite-bun/src/SqliteClient.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ export const make = (
105105
Effect.withFiberRuntime<Array<any>, SqlError>((fiber) => {
106106
const useSafeIntegers = Context.get(fiber.currentContext, Client.SafeIntegers)
107107
const statement = db.query(sql)
108-
109108
// @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
110109
statement.safeIntegers(useSafeIntegers)
111-
return Effect.try({
112-
try: () => (statement.all(...(params as any)) ?? []) as Array<any>,
113-
catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
114-
})
110+
try {
111+
return Effect.succeed((statement.all(...(params as any)) ?? []) as Array<any>)
112+
} catch (cause) {
113+
return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
114+
}
115115
})
116116

117117
const runValues = (
@@ -121,13 +121,13 @@ export const make = (
121121
Effect.withFiberRuntime<Array<any>, SqlError>((fiber) => {
122122
const useSafeIntegers = Context.get(fiber.currentContext, Client.SafeIntegers)
123123
const statement = db.query(sql)
124-
125124
// @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
126125
statement.safeIntegers(useSafeIntegers)
127-
return Effect.try({
128-
try: () => (statement.values(...(params as any)) ?? []) as Array<any>,
129-
catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
130-
})
126+
try {
127+
return Effect.succeed((statement.values(...(params as any)) ?? []) as Array<any>)
128+
} catch (cause) {
129+
return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
130+
}
131131
})
132132

133133
return identity<SqliteConnection>({

0 commit comments

Comments
 (0)