From b24bc7d777daea69ae87c78d09885bc76597f71c Mon Sep 17 00:00:00 2001 From: aacebo Date: Mon, 2 Dec 2024 00:47:54 +0800 Subject: [PATCH] add error keys --- gq/bool.go | 2 +- gq/date.go | 2 +- gq/float.go | 2 +- gq/int.go | 2 +- gq/string.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gq/bool.go b/gq/bool.go index d61af5d..bc7c170 100644 --- a/gq/bool.go +++ b/gq/bool.go @@ -23,7 +23,7 @@ func (self Bool) Resolve(params *ResolveParams) Result { return Result{Data: value} } - return Result{Error: NewError("", "must be a boolean")} + return Result{Error: NewError(params.Key, "must be a boolean")} } func (self Bool) MarshalJSON() ([]byte, error) { diff --git a/gq/date.go b/gq/date.go index 45314aa..0a95012 100644 --- a/gq/date.go +++ b/gq/date.go @@ -24,7 +24,7 @@ func (self Date) Resolve(params *ResolveParams) Result { return Result{Data: value} } - return Result{Error: NewError("", "must be a Date")} + return Result{Error: NewError(params.Key, "must be a Date")} } func (self Date) MarshalJSON() ([]byte, error) { diff --git a/gq/float.go b/gq/float.go index 3d27cb6..9086cc0 100644 --- a/gq/float.go +++ b/gq/float.go @@ -25,7 +25,7 @@ func (self Float) Resolve(params *ResolveParams) Result { return Result{Data: value} } - return Result{Error: NewError("", "must be a float")} + return Result{Error: NewError(params.Key, "must be a float")} } func (self Float) MarshalJSON() ([]byte, error) { diff --git a/gq/int.go b/gq/int.go index 2fb978b..fc63805 100644 --- a/gq/int.go +++ b/gq/int.go @@ -25,7 +25,7 @@ func (self Int) Resolve(params *ResolveParams) Result { return Result{Data: value.Interface()} } - return Result{Error: NewError("", "must be an integer")} + return Result{Error: NewError(params.Key, "must be an integer")} } func (self Int) MarshalJSON() ([]byte, error) { diff --git a/gq/string.go b/gq/string.go index 14b0e53..1fd3dac 100644 --- a/gq/string.go +++ b/gq/string.go @@ -23,7 +23,7 @@ func (self String) Resolve(params *ResolveParams) Result { return Result{Data: value} } - return Result{Error: NewError("", "must be a string")} + return Result{Error: NewError(params.Key, "must be a string")} } func (self String) MarshalJSON() ([]byte, error) {