feat(error):增加数据不足的错误类型。

This commit is contained in:
徐涛 2023-06-17 09:30:48 +08:00
parent db52a140b1
commit e5dadf06be

View 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)
}