Check error type after running a query #741
Answered
by
alejandrozuleta
alejandrozuleta
asked this question in
Q&A
-
Are there predefined error types that I can use to check if the returned error is an specific error, namely PostgreSQL's duplicated key value violation? For example: _, err := u.DB.NewInsert().Model(model).Exec(ctx)
if err == bun.DuplicatedKeyValueError {
// Do something
} How is this supposed to be handled? |
Beta Was this translation helpful? Give feedback.
Answered by
alejandrozuleta
Jan 3, 2023
Replies: 1 comment
-
It seems there is a way to check specific errors for PostgreSQL, it is documented here: |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
alejandrozuleta
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems there is a way to check specific errors for PostgreSQL, it is documented here:
https://bun.uptrace.dev/postgres/#pgdriver-error