Skip to content

Commit bc1024c

Browse files
Inline sqlite error classification (#1515)
1 parent a1c428b commit bc1024c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

apps/server/src/persistence/NodeSqliteClient.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export const TypeId: TypeId = "~local/sqlite-node/SqliteClient";
2929

3030
export type TypeId = "~local/sqlite-node/SqliteClient";
3131

32-
const classifyError = (cause: unknown, message: string, operation: string) =>
33-
classifySqliteError(cause, { message, operation });
34-
3532
/**
3633
* SqliteClient - Effect service tag for the sqlite SQL client.
3734
*/
@@ -114,7 +111,10 @@ const makeWithDatabase = (
114111
try: () => db.prepare(sql),
115112
catch: (cause) =>
116113
new SqlError({
117-
reason: classifyError(cause, "Failed to prepare statement", "prepare"),
114+
reason: classifySqliteError(cause, {
115+
message: "Failed to prepare statement",
116+
operation: "prepare",
117+
}),
118118
}),
119119
}),
120120
});
@@ -135,7 +135,10 @@ const makeWithDatabase = (
135135
} catch (cause) {
136136
return Effect.fail(
137137
new SqlError({
138-
reason: classifyError(cause, "Failed to execute statement", "execute"),
138+
reason: classifySqliteError(cause, {
139+
message: "Failed to execute statement",
140+
operation: "execute",
141+
}),
139142
}),
140143
);
141144
}
@@ -162,7 +165,10 @@ const makeWithDatabase = (
162165
},
163166
catch: (cause) =>
164167
new SqlError({
165-
reason: classifyError(cause, "Failed to execute statement", "execute"),
168+
reason: classifySqliteError(cause, {
169+
message: "Failed to execute statement",
170+
operation: "execute",
171+
}),
166172
}),
167173
}),
168174
(statement) =>

0 commit comments

Comments
 (0)