From ac5bbb08c078a2e0a3d58382798cc3ec0ebcd7d3 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Wed, 17 Jan 2024 11:43:07 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Rename=20getter=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- errorf.go | 4 ++-- errorf_test.go | 8 ++++---- interface.go | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/errorf.go b/errorf.go index 0f34db5..40e2e1d 100644 --- a/errorf.go +++ b/errorf.go @@ -26,7 +26,7 @@ type erf struct { msg string } -func (e *erf) Status() int { +func (e *erf) GetStatus() int { return e.stat } @@ -34,7 +34,7 @@ func (e *erf) Error() string { return e.msg } -func (e *erf) Msg() string { +func (e *erf) GetMsg() string { return e.msg } diff --git a/errorf_test.go b/errorf_test.go index 314e0ee..f48b0a5 100644 --- a/errorf_test.go +++ b/errorf_test.go @@ -28,8 +28,8 @@ func (s *ErrorfTestSuite) TestNoWrap() { exp := "42 is more than 13" s.Assert().Equal(exp, err.Error()) - s.Assert().Equal(exp, err.Msg()) - s.Assert().Equal(http.StatusTeapot, err.Status()) + s.Assert().Equal(exp, err.GetMsg()) + s.Assert().Equal(http.StatusTeapot, err.GetStatus()) } func (s *ErrorfTestSuite) TestWrapOne() { @@ -45,7 +45,7 @@ func (s *ErrorfTestSuite) TestWrapOne() { exp := "I'm a little teapot. Here is my handle." s.Assert().Equal(exp, we.Error()) - s.Assert().Equal(exp, we.Msg()) + s.Assert().Equal(exp, we.GetMsg()) s.Assert().Same(wrapped, we.Unwrap()) } @@ -63,7 +63,7 @@ func (s *ErrorfTestSuite) TestWrapTwo() { exp := "I'm a little teapot: short and stout. Here is my handle." s.Assert().Equal(exp, we.Error()) - s.Assert().Equal(exp, we.Msg()) + s.Assert().Equal(exp, we.GetMsg()) unwrapped := we.Unwrap() s.Assert().Len(unwrapped, 2) s.Assert().Same(wrappedOne, unwrapped[0]) diff --git a/interface.go b/interface.go index 516cc2c..4a687d6 100644 --- a/interface.go +++ b/interface.go @@ -3,13 +3,13 @@ package errors // ResponsableError is an error that has information useful in an HTTP response. // The string returned by Error should be suitable for logging useful information // to assist debugging the error. -// Status should return an appropriate HTTP status. -// Msg should return a message suitable to display to the end user. If the message +// GetStatus should return an appropriate HTTP status. +// GetMsg should return a message suitable to display to the end user. If the message // returned by Error is safe for the end user, it may simply call that. type ResponsableError interface { Error() string - Status() int - Msg() string + GetStatus() int + GetMsg() string } // UnwrappableError allows a ResponsableError to wrap another error.