mirror of https://github.com/jackc/pgx.git
pgconn.SafeToRetry checks for wrapped errors
Use errors.As instead of type assertion. Port 4e2e7a040579c1999c0766642d836eb28c6e2018 to v5 Credit to tjaskopull/2010/head
parent
01d649b2bf
commit
579a320c1c
|
@ -12,8 +12,9 @@ import (
|
||||||
|
|
||||||
// SafeToRetry checks if the err is guaranteed to have occurred before sending any data to the server.
|
// SafeToRetry checks if the err is guaranteed to have occurred before sending any data to the server.
|
||||||
func SafeToRetry(err error) bool {
|
func SafeToRetry(err error) bool {
|
||||||
if e, ok := err.(interface{ SafeToRetry() bool }); ok {
|
var retryableErr interface{ SafeToRetry() bool }
|
||||||
return e.SafeToRetry()
|
if errors.As(err, &retryableErr) {
|
||||||
|
return retryableErr.SafeToRetry()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue