Skip to content

Commit

Permalink
fix: wrap full validation errors instead of just their message (#232)
Browse files Browse the repository at this point in the history
This PR contains a simple adjustment to the error handling of the struct field validation.
Previously only the string representation of the error was included in the returned
`SDKError`, but an upcoming change to the CLI plugins requires the actual error
object, because it contains valuable information.

Signed-off-by: Norbert Biczo <[email protected]>
  • Loading branch information
pyrooka authored Dec 12, 2024
1 parent 8da480a commit 1bfb146
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func ValidateStruct(param interface{}, paramName string) error {
if err != nil {
// If there were validation errors then return an error containing the field errors
if fieldErrors, ok := err.(validator.ValidationErrors); ok {
err = fmt.Errorf("%s failed validation:\n%s", paramName, fieldErrors.Error())
err = fmt.Errorf("%s failed validation:\n%w", paramName, fieldErrors)
return SDKErrorf(err, "", "struct-validation-errors", getComponentInfo())
}
return SDKErrorf(err, "", "struct-validate-unknown-error", getComponentInfo())
Expand Down

0 comments on commit 1bfb146

Please sign in to comment.