mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 18:15:59 +08:00
error
This commit is contained in:
+2
-34
@@ -7,16 +7,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Code interface {
|
||||
type Coderr interface {
|
||||
Code() int
|
||||
Msg() string
|
||||
}
|
||||
|
||||
type Coderr interface {
|
||||
Code
|
||||
Detail() string
|
||||
WithDetail(string) Coderr
|
||||
Warp(...string) error
|
||||
Warp(msg ...string) error
|
||||
error
|
||||
}
|
||||
|
||||
@@ -33,15 +27,6 @@ type errInfo struct {
|
||||
detail string
|
||||
}
|
||||
|
||||
func (e *errInfo) WithDetail(s string) Coderr {
|
||||
if e.detail == "" {
|
||||
e.detail = s
|
||||
} else {
|
||||
e.detail = s + ", " + e.detail
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *errInfo) Code() int {
|
||||
return e.code
|
||||
}
|
||||
@@ -50,10 +35,6 @@ func (e *errInfo) Msg() string {
|
||||
return e.msg
|
||||
}
|
||||
|
||||
func (e *errInfo) Detail() string {
|
||||
return e.detail
|
||||
}
|
||||
|
||||
func (e *errInfo) Warp(w ...string) error {
|
||||
return errors.Wrap(e, strings.Join(w, ", "))
|
||||
}
|
||||
@@ -65,16 +46,3 @@ func (e *errInfo) Error() string {
|
||||
func Unwrap(err error) error {
|
||||
return utils.Unwrap(err)
|
||||
}
|
||||
|
||||
func GetCode(err error) Code {
|
||||
if err == nil {
|
||||
return NewCodeError(UnknownCode, "nil")
|
||||
}
|
||||
if code, ok := Unwrap(err).(Code); ok {
|
||||
if code.Code() == 0 {
|
||||
return NewCodeError(UnknownCode, "code == 0")
|
||||
}
|
||||
return code
|
||||
}
|
||||
return NewCodeError(UnknownCode, "unknown code")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user