Skip to content

Is there a way to differentiate between errors returned by .Insert() etc? #1349

Answered by stephenafamo
SamusAranX asked this question in Q&A
Discussion options

You must be logged in to vote

SQLBoiler wraps errors from the database driver, so you need to look at the the documentation of your driver and see how to tell the errors apart.

I wrote an article in 2021 about doing this for PostgreSQL using the github.com/lib/pq driver. https://stephenafamo.com/blog/posts/handling-postgresql-errors

There is also a wiki entry for pgx: https://github.com/jackc/pgx/wiki/Error-Handling

If you're using MySQL, SQLite or SQL Server, the patters will be the same, but you'd need to find the underlying error type and use errors.As to get that concrete error.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by stephenafamo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants