History

Inline sqlite error classification (#1515)

Julius Marminge committed 7 months ago

Commit bc1024c1 parent a1c428b1 file · +12 −6Browse files

Unified · Split

apps/server/src/persistence/NodeSqliteClient.ts+12−6
@@ -29,9 +29,6 @@ export const TypeId: TypeId = "~local/sqlite-node/SqliteClient"; · 28 unmodified lines
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 = ( · 76 unmodified lines
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 = ( · 14 unmodified lines
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 = ( · 20 unmodified lines
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) =>