mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-10 03:56:00 +08:00
s3
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
type CodeError interface {
|
||||
Code() int
|
||||
Msg() string
|
||||
Is(err error) bool
|
||||
Wrap(msg ...string) error
|
||||
error
|
||||
}
|
||||
@@ -38,6 +39,17 @@ func (e *codeError) Wrap(w ...string) error {
|
||||
return errors.Wrap(e, strings.Join(w, ", "))
|
||||
}
|
||||
|
||||
func (e *codeError) Is(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
codeErr, ok := Unwrap(err).(CodeError)
|
||||
if ok {
|
||||
return codeErr.Code() == e.code
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e *codeError) Error() string {
|
||||
return fmt.Sprintf("[%d]%s", e.code, e.msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user