You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
437 B
Go

5 months ago
package e
5 months ago
import sysErr "errors"
5 months ago
type Error struct {
5 months ago
Code string
Message string
}
5 months ago
func (e *Error) Error() string {
5 months ago
return e.Message
}
5 months ago
func NewError(message ...string) *Error {
err := &Error{
5 months ago
"1000",
"业务错误",
}
if len(message) == 0 {
return err
}
err.Message = message[0]
if len(message) > 1 {
err.Code = message[1]
}
return err
}
func Is(err error, target error) bool {
return sysErr.Is(err, target)
}