Examples for Error Handling?

I am looking through docs on how to handle DB errors, but not finding a list of error codes. For example, UNIQUE or NOT NULL constraints to check for. Or is this something I need to look at Postgres.js docs for? Pseudocode below using Sqlite, but want to know for Postgres.js
try {
...
} catch (e) {
if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") {
return setError(form, 'email', "E-mail already used")
}
}
try {
...
} catch (e) {
if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") {
return setError(form, 'email', "E-mail already used")
}
}
1 Reply
kal
kal6mo ago
Did you figure this out in the end
Want results from more Discord servers?
Add your server