feat(error):增加数据不足的错误类型。
This commit is contained in:
parent
db52a140b1
commit
e5dadf06be
16
exceptions/insufficient_data.go
Normal file
16
exceptions/insufficient_data.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package exceptions
|
||||
|
||||
import "fmt"
|
||||
|
||||
type InsufficientDataError struct {
|
||||
Field string
|
||||
Message string
|
||||
}
|
||||
|
||||
func NewInsufficientDataError(field, msg string) *InsufficientDataError {
|
||||
return &InsufficientDataError{Field: field, Message: msg}
|
||||
}
|
||||
|
||||
func (e InsufficientDataError) Error() string {
|
||||
return fmt.Sprintf("字段 [%s] 数据不足,%s", e.Field, e.Message)
|
||||
}
|
Loading…
Reference in New Issue
Block a user