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.
26 lines
364 B
Go
26 lines
364 B
Go
7 months ago
|
package errors
|
||
|
|
||
|
type BizError struct {
|
||
|
Code string
|
||
|
Message string
|
||
|
}
|
||
|
|
||
|
func (e *BizError) Error() string {
|
||
|
return e.Message
|
||
|
}
|
||
|
|
||
|
func NewBusinessError(message ...string) *BizError {
|
||
|
err := &BizError{
|
||
|
"1000",
|
||
|
"业务错误",
|
||
|
}
|
||
|
if len(message) == 0 {
|
||
|
return err
|
||
|
}
|
||
|
err.Message = message[0]
|
||
|
if len(message) > 1 {
|
||
|
err.Code = message[1]
|
||
|
}
|
||
|
return err
|
||
|
}
|