mirror of https://github.com/tikv/client-go.git
errors: use As to check error type (#361)
This commit is contained in:
parent
5a13df80a6
commit
c0efee0618
|
|
@ -131,8 +131,8 @@ func (k *ErrKeyExist) Error() string {
|
||||||
|
|
||||||
// IsErrKeyExist returns true if it is ErrKeyExist.
|
// IsErrKeyExist returns true if it is ErrKeyExist.
|
||||||
func IsErrKeyExist(err error) bool {
|
func IsErrKeyExist(err error) bool {
|
||||||
_, ok := errors.Cause(err).(*ErrKeyExist)
|
var e *ErrKeyExist
|
||||||
return ok
|
return errors.As(err, &e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrWriteConflict wraps *kvrpcpb.ErrWriteConflict to implement the error interface.
|
// ErrWriteConflict wraps *kvrpcpb.ErrWriteConflict to implement the error interface.
|
||||||
|
|
@ -146,8 +146,8 @@ func (k *ErrWriteConflict) Error() string {
|
||||||
|
|
||||||
// IsErrWriteConflict returns true if it is ErrWriteConflict.
|
// IsErrWriteConflict returns true if it is ErrWriteConflict.
|
||||||
func IsErrWriteConflict(err error) bool {
|
func IsErrWriteConflict(err error) bool {
|
||||||
_, ok := errors.Cause(err).(*ErrWriteConflict)
|
var e *ErrWriteConflict
|
||||||
return ok
|
return errors.As(err, &e)
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewErrWriteConfictWithArgs generates an ErrWriteConflict with args.
|
//NewErrWriteConfictWithArgs generates an ErrWriteConflict with args.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue