yjp hace 3 años
padre
commit
676bfee428
Se han modificado 1 ficheros con 9 adiciones y 0 borrados
  1. 9 0
      errors.go

+ 9 - 0
errors.go

@@ -25,6 +25,15 @@ var codeMap = map[uint32]string{
 	ErrCustomCode:       "自定义错误",
 }
 
+func NewFromError(err error) error {
+	_, ok := err.(*Error)
+	if ok {
+		return err
+	}
+
+	return NewUnknownError(err.Error())
+}
+
 func NewUnknownError(message string) error {
 	return newError(ErrUnknownCode, message)
 }