mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 02:26:00 +08:00
error
This commit is contained in:
+12
-4
@@ -1,7 +1,6 @@
|
||||
package errs
|
||||
|
||||
import (
|
||||
"OpenIM/pkg/utils"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
type Coderr interface {
|
||||
Code() int
|
||||
Msg() string
|
||||
Warp(msg ...string) error
|
||||
Wrap(msg ...string) error
|
||||
error
|
||||
}
|
||||
|
||||
@@ -35,7 +34,7 @@ func (e *errInfo) Msg() string {
|
||||
return e.msg
|
||||
}
|
||||
|
||||
func (e *errInfo) Warp(w ...string) error {
|
||||
func (e *errInfo) Wrap(w ...string) error {
|
||||
return errors.Wrap(e, strings.Join(w, ", "))
|
||||
}
|
||||
|
||||
@@ -44,5 +43,14 @@ func (e *errInfo) Error() string {
|
||||
}
|
||||
|
||||
func Unwrap(err error) error {
|
||||
return utils.Unwrap(err)
|
||||
for err != nil {
|
||||
unwrap, ok := err.(interface {
|
||||
Unwrap() error
|
||||
})
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
err = unwrap.Unwrap()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user