Inline sqlite error classification (#1515)
This commit is contained in:
1 parent
a1c428b6e2
commit
bc1024caf0
1 file changed
+12
-6
@@ -29,9 +29,6 @@ export const TypeId: TypeId = "~local/sqlite-node/SqliteClient";
|
||||
|
||||
export type TypeId = "~local/sqlite-node/SqliteClient";
|
||||
|
||||
const classifyError = (cause: unknown, message: string, operation: string) =>
|
||||
classifySqliteError(cause, { message, operation });
|
||||
|
||||
/**
|
||||
* SqliteClient - Effect service tag for the sqlite SQL client.
|
||||
*/
|
||||
@@ -114,7 +111,10 @@ const makeWithDatabase = (
|
||||
try: () => db.prepare(sql),
|
||||
catch: (cause) =>
|
||||
new SqlError({
|
||||
reason: classifyError(cause, "Failed to prepare statement", "prepare"),
|
||||
reason: classifySqliteError(cause, {
|
||||
message: "Failed to prepare statement",
|
||||
operation: "prepare",
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
@@ -135,7 +135,10 @@ const makeWithDatabase = (
|
||||
} catch (cause) {
|
||||
return Effect.fail(
|
||||
new SqlError({
|
||||
reason: classifyError(cause, "Failed to execute statement", "execute"),
|
||||
reason: classifySqliteError(cause, {
|
||||
message: "Failed to execute statement",
|
||||
operation: "execute",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -162,7 +165,10 @@ const makeWithDatabase = (
|
||||
},
|
||||
catch: (cause) =>
|
||||
new SqlError({
|
||||
reason: classifyError(cause, "Failed to execute statement", "execute"),
|
||||
reason: classifySqliteError(cause, {
|
||||
message: "Failed to execute statement",
|
||||
operation: "execute",
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
(statement) =>
|
||||
|
||||
Reference in new issue
Block a user