🚚 Rename getter methods

This commit is contained in:
Dan Jones 2024-01-17 11:43:07 -06:00
commit ac5bbb08c0
3 changed files with 10 additions and 10 deletions

View file

@ -26,7 +26,7 @@ type erf struct {
msg string msg string
} }
func (e *erf) Status() int { func (e *erf) GetStatus() int {
return e.stat return e.stat
} }
@ -34,7 +34,7 @@ func (e *erf) Error() string {
return e.msg return e.msg
} }
func (e *erf) Msg() string { func (e *erf) GetMsg() string {
return e.msg return e.msg
} }

View file

@ -28,8 +28,8 @@ func (s *ErrorfTestSuite) TestNoWrap() {
exp := "42 is more than 13" exp := "42 is more than 13"
s.Assert().Equal(exp, err.Error()) s.Assert().Equal(exp, err.Error())
s.Assert().Equal(exp, err.Msg()) s.Assert().Equal(exp, err.GetMsg())
s.Assert().Equal(http.StatusTeapot, err.Status()) s.Assert().Equal(http.StatusTeapot, err.GetStatus())
} }
func (s *ErrorfTestSuite) TestWrapOne() { func (s *ErrorfTestSuite) TestWrapOne() {
@ -45,7 +45,7 @@ func (s *ErrorfTestSuite) TestWrapOne() {
exp := "I'm a little teapot. Here is my handle." exp := "I'm a little teapot. Here is my handle."
s.Assert().Equal(exp, we.Error()) s.Assert().Equal(exp, we.Error())
s.Assert().Equal(exp, we.Msg()) s.Assert().Equal(exp, we.GetMsg())
s.Assert().Same(wrapped, we.Unwrap()) 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." exp := "I'm a little teapot: short and stout. Here is my handle."
s.Assert().Equal(exp, we.Error()) s.Assert().Equal(exp, we.Error())
s.Assert().Equal(exp, we.Msg()) s.Assert().Equal(exp, we.GetMsg())
unwrapped := we.Unwrap() unwrapped := we.Unwrap()
s.Assert().Len(unwrapped, 2) s.Assert().Len(unwrapped, 2)
s.Assert().Same(wrappedOne, unwrapped[0]) s.Assert().Same(wrappedOne, unwrapped[0])

View file

@ -3,13 +3,13 @@ package errors
// ResponsableError is an error that has information useful in an HTTP response. // ResponsableError is an error that has information useful in an HTTP response.
// The string returned by Error should be suitable for logging useful information // The string returned by Error should be suitable for logging useful information
// to assist debugging the error. // to assist debugging the error.
// Status should return an appropriate HTTP status. // GetStatus should return an appropriate HTTP status.
// Msg should return a message suitable to display to the end user. If the message // 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. // returned by Error is safe for the end user, it may simply call that.
type ResponsableError interface { type ResponsableError interface {
Error() string Error() string
Status() int GetStatus() int
Msg() string GetMsg() string
} }
// UnwrappableError allows a ResponsableError to wrap another error. // UnwrappableError allows a ResponsableError to wrap another error.