From 8cf1136f961a6b4e9ab7de33ac2d0d2f78fb5113 Mon Sep 17 00:00:00 2001 From: Jacob <57016439+jbohanon@users.noreply.github.com> Date: Tue, 22 Feb 2022 14:57:07 -0500 Subject: [PATCH] Add Useful Error Message for TVP Elem Types Error message ErrorTypeSlice is misleading when returned as a result of the types of the elements of the slice not being structs. Added a more useful error message to elaborate on the particular error. --- tvp_go19.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tvp_go19.go b/tvp_go19.go index 32485a1b..d135b626 100644 --- a/tvp_go19.go +++ b/tvp_go19.go @@ -23,6 +23,7 @@ const ( var ( ErrorEmptyTVPTypeName = errors.New("TypeName must not be empty") ErrorTypeSlice = errors.New("TVP must be slice type") + ErrorTypeSliceStructs = errors.New("TVP must be slice type with struct type elements") ErrorTypeSliceIsEmpty = errors.New("TVP mustn't be null value") ErrorSkip = errors.New("all fields mustn't skip") ErrorObjectName = errors.New("wrong tvp name") @@ -55,7 +56,7 @@ func (tvp TVP) check() error { return ErrorTypeSliceIsEmpty } if reflect.TypeOf(tvp.Value).Elem().Kind() != reflect.Struct { - return ErrorTypeSlice + return ErrorTypeSliceStructs } return nil }