From 1fe03077119f3f40d5cb58ccf983d1a5fb37997a Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 3 Dec 2020 16:23:59 +0300 Subject: [PATCH] [#223] pkg/object: Work with SplitInfoError via pointer Closes #221 Signed-off-by: Alex Vanin --- pkg/object/error.go | 8 ++++---- pkg/object/error_test.go | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/object/error.go b/pkg/object/error.go index 98bd3f2..96048c2 100644 --- a/pkg/object/error.go +++ b/pkg/object/error.go @@ -6,14 +6,14 @@ type SplitInfoError struct { const splitInfoErrorMsg = "object not found, split info has been provided" -func (s SplitInfoError) Error() string { +func (s *SplitInfoError) Error() string { return splitInfoErrorMsg } -func (s SplitInfoError) SplitInfo() *SplitInfo { +func (s *SplitInfoError) SplitInfo() *SplitInfo { return s.si } -func NewSplitInfoError(v *SplitInfo) SplitInfoError { - return SplitInfoError{si: v} +func NewSplitInfoError(v *SplitInfo) *SplitInfoError { + return &SplitInfoError{si: v} } diff --git a/pkg/object/error_test.go b/pkg/object/error_test.go index ce3bcd2..870c2d6 100644 --- a/pkg/object/error_test.go +++ b/pkg/object/error_test.go @@ -12,12 +12,13 @@ func TestNewSplitInfoError(t *testing.T) { var ( si = generateSplitInfo() - err error = object.NewSplitInfoError(si) + err error = object.NewSplitInfoError(si) + expectedErr *object.SplitInfoError ) - require.True(t, errors.As(err, new(object.SplitInfoError))) + require.True(t, errors.As(err, &expectedErr)) - siErr, ok := err.(object.SplitInfoError) + siErr, ok := err.(*object.SplitInfoError) require.True(t, ok) require.Equal(t, si, siErr.SplitInfo()) }