Error handling of query (constraints, SQLite) #1282
-
This is both a SQL and SQLx question. CREATE TABLE Items (
shelf INTEGER NOT NULL,
...,
UNIQUE(shelf)
); Let's say that a table contains items which are placed on a shelf each. I'm struggling to find a way to find out whether the query failed because the planets have aligned or simply because I saw a I don't know if this is even possible, or if I shouldn't do this in the first place. Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The See https://www.sqlite.org/rescode.html for more codes. It could make sense to have a |
Beta Was this translation helpful? Give feedback.
The
.code()
method onSqliteError
should return"2067"
for a unique failure. You can't get the exact constraint name with sqlite but you'll at least know its because of a unique constraint.See https://www.sqlite.org/rescode.html for more codes. It could make sense to have a
SqliteErrorKind
likestd::io::ErrorKind
to enum those.