Skip to content

Commit

Permalink
add error keys
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebo committed Dec 1, 2024
1 parent 3d32526 commit b24bc7d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gq/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gq/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gq/float.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gq/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gq/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b24bc7d

Please sign in to comment.