-
-
Notifications
You must be signed in to change notification settings - Fork 944
Open
Labels
Description
I've written something like
const uniquenessViolation = pq.ErrorCode("23505")
...
if pgerr, ok := err.(*pq.Error); ok {
if pgerr.Code == uniquenessViolation {
return ErrSomeSpecificErrorForAPINiceness
}
}
a few times in various packages.
Maybe I'm doing something wrong by doing this, but it might be nice to have some funcs named things like pq.IsUniquenessViolation(error) to help out on this sort of thing. It seems like we could generate them once from the errorCodeNames maps (while handling the "000" class cases by ignoring them or checking for the class or whichever way you'd like).
Does this sound like a patch you'd accept?
Reactions are currently unavailable