From e5dadf06be0060018e26052559ff2a62c0cf4f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sat, 17 Jun 2023 09:30:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(error):=E5=A2=9E=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8D=E8=B6=B3=E7=9A=84=E9=94=99=E8=AF=AF=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exceptions/insufficient_data.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 exceptions/insufficient_data.go diff --git a/exceptions/insufficient_data.go b/exceptions/insufficient_data.go new file mode 100644 index 0000000..45a2047 --- /dev/null +++ b/exceptions/insufficient_data.go @@ -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) +}