mirror of
https://github.com/nkanaev/yarr.git
synced 2026-06-24 09:05:16 +00:00
add lib/pq
This commit is contained in:
23
vendor/github.com/lib/pq/as_go126.go
generated
vendored
Normal file
23
vendor/github.com/lib/pq/as_go126.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
//go:build go1.26
|
||||
|
||||
package pq
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/lib/pq/pqerror"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// As asserts that the given error is [pq.Error] and returns it, returning nil
|
||||
// if it's not a pq.Error.
|
||||
//
|
||||
// It will return nil if the pq.Error is not one of the given error codes. If no
|
||||
// codes are given it will always return the Error.
|
||||
//
|
||||
// This is safe to call with a nil error.
|
||||
func As(err error, codes ...pqerror.Code) *Error {
|
||||
if pqErr, ok := errors.AsType[*Error](err); ok && (len(codes) == 0 || slices.Contains(codes, pqErr.Code)) {
|
||||
return pqErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user