From 1bfb146dfb85a470a7f0c70854252551853f89bb Mon Sep 17 00:00:00 2001 From: Norbert Biczo Date: Thu, 12 Dec 2024 15:20:05 +0100 Subject: [PATCH] fix: wrap full validation errors instead of just their message (#232) 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 --- core/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/utils.go b/core/utils.go index 72e26c2..1075799 100644 --- a/core/utils.go +++ b/core/utils.go @@ -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())