2019-06-26 08:38:07 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package errs2
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zeebo/errs"
|
2019-09-19 05:46:39 +01:00
|
|
|
|
|
|
|
"storj.io/storj/pkg/rpc/rpcstatus"
|
2019-06-26 08:38:07 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// IsRPC checks if err contains an RPC error with the given status code.
|
2019-09-19 05:46:39 +01:00
|
|
|
func IsRPC(err error, code rpcstatus.StatusCode) bool {
|
2019-06-26 08:38:07 +01:00
|
|
|
return errs.IsFunc(err, func(err error) bool {
|
2019-09-19 05:46:39 +01:00
|
|
|
return rpcstatus.Code(err) == code
|
2019-06-26 08:38:07 +01:00
|
|
|
})
|
|
|
|
}
|