blob: c5c64153a0d38edf13176eeb49eb7bda3a9eadce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import type { PostgresError } from "../types/database.js";
export function isPostgresError(error: unknown): error is PostgresError {
return (
error instanceof Error &&
"code" in error &&
typeof (error as PostgresError).code === "string"
);
}
export const PostgresErrorCodes = {
UNIQUE_VIOLATION: "23505",
FOREIGN_KEY_VIOLATION: "23503",
NOT_NULL_VIOLATION: "23502",
CHECK_VIOLATION: "23514",
};
|