diff --git a/bad_request.go b/bad_request.go index 4361271..1235b86 100644 --- a/bad_request.go +++ b/bad_request.go @@ -19,7 +19,7 @@ package pathmatch // fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error()) // return // -// case pathmatch.InternalErrorComplainer: +// case pathmatch.InternalError: // // fmt.Printf("It's not your fault; it's our fault. Something bad happened internally when pathmatch.Compile() was running. The error message was....\n%s\n", err.Error()) // return @@ -46,7 +46,7 @@ package pathmatch // fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error()) // return // -// case pathmatch.InternalErrorComplainer: +// case pathmatch.InternalError: // // fmt.Printf("It's not your fault; it's our fault. Something bad happened internally when pathmatch.Compile() was running. The error message was....\n%s\n", err.Error()) // return @@ -70,7 +70,7 @@ package pathmatch // fmt.Printf("Something you did when you called pattern.Match() caused an error. The error message was....\n%s\n", err.Error()) // return // -// case pathmatch.InternalErrorComplainer: +// case pathmatch.InternalError: // // fmt.Printf("It's not your fault; it's our fault. Something bad happened internally when pattern.Match() was running. The error message was....\n%s\n", err.Error()) // return @@ -103,7 +103,7 @@ package pathmatch // fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error()) // return // -// case pathmatch.InternalErrorComplainer: +// case pathmatch.InternalError: // // fmt.Printf("It's not your fault; it's our fault. Something bad happened internally when pathmatch.Compile() was running. The error message was....\n%s\n", err.Error()) // return diff --git a/internal_error_complainer.go b/internal_error_complainer.go index fdf91ea..35294a4 100644 --- a/internal_error_complainer.go +++ b/internal_error_complainer.go @@ -1,46 +1,40 @@ package pathmatch - import ( "bytes" "fmt" ) - const ( internalErrorMessagePrefix = "Internal Error: " ) - -type InternalErrorComplainer interface { +type InternalError interface { error - InternalErrorComplainer() + InternalError() } - -// internalInternalErrorComplainer is the only underlying implementation that fits the -// InternalErrorComplainer interface, in this library. -type internalInternalErrorComplainer struct { +// internalInternalError is the only underlying implementation that fits the +// InternalError interface, in this library. +type internalInternalError struct { msg string } - -// newInternalErrorComplainer creates a new internalInternalErrorComplainer (struct) and -// returns it as a InternalErrorComplainer (interface). -func newInternalErrorComplainer(format string, a ...interface{}) InternalErrorComplainer { +// newInternalError creates a new internalInternalError (struct) and +// returns it as a InternalError (interface). +func newInternalError(format string, a ...interface{}) InternalError { msg := fmt.Sprintf(format, a...) - err := internalInternalErrorComplainer{ + err := internalInternalError{ msg:msg, } return &err } - -// Error method is necessary to satisfy the 'error' interface (and the InternalErrorComplainer +// Error method is necessary to satisfy the 'error' interface (and the InternalError // interface). -func (err *internalInternalErrorComplainer) Error() string { +func (err *internalInternalError) Error() string { var buffer bytes.Buffer buffer.WriteString(internalErrorMessagePrefix) @@ -49,9 +43,8 @@ func (err *internalInternalErrorComplainer) Error() string { return buffer.String() } - -// InternalErrorComplainer method is necessary to satisfy the 'InternalErrorComplainer' interface. +// InternalError method is necessary to satisfy the 'InternalError' interface. // It exists to make this error type detectable in a Go type-switch. -func (err *internalInternalErrorComplainer) InternalErrorComplainer() { +func (err *internalInternalError) InternalError() { // Nothing here. } diff --git a/pattern_match.go b/pattern_match.go index 1eff347..2cd5533 100644 --- a/pattern_match.go +++ b/pattern_match.go @@ -12,7 +12,7 @@ const ( var ( - errThisShouldNeverHappen = newInternalErrorComplainer("This should never happen.") + errThisShouldNeverHappen = newInternalError("This should never happen.") ) diff --git a/pattern_syntax_error_complainer.go b/pattern_syntax_error_complainer.go index e422911..94c1cea 100644 --- a/pattern_syntax_error_complainer.go +++ b/pattern_syntax_error_complainer.go @@ -26,7 +26,7 @@ import ( // fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error()) // return // -// case pathmatch.InternalErrorComplainer: +// case pathmatch.InternalError: // // fmt.Printf("It's not your fault; it's our fault. Something bad happened internally when pathmatch.Compile() was running. The error message was....\n%s\n", err.Error()) // return @@ -71,7 +71,7 @@ func (err *internalPatternSyntaxErrorComplainer) Error() string { } -// BadRequest method is necessary to satisfy the 'InternalErrorComplainer' interface. +// BadRequest method is necessary to satisfy the 'InternalError' interface. // It exists to make this error type detectable in a Go type-switch. func (err *internalPatternSyntaxErrorComplainer) BadRequest() { // Nothing here. diff --git a/scan_error.go b/scan_error.go index 5cfc8dd..6d95455 100644 --- a/scan_error.go +++ b/scan_error.go @@ -5,7 +5,7 @@ import ( ) type ScanError interface { - InternalErrorComplainer + InternalError ScanError() WrappedError() error } @@ -37,9 +37,9 @@ func (err *internalScanError) Error() string { return s } -// InternalErrorComplainer method is necessary to satisfy the 'InternalErrorComplainer' interface. +// InternalError method is necessary to satisfy the 'InternalError' interface. // It exists to make this error type detectable in a Go type-switch. -func (err *internalScanError) InternalErrorComplainer() { +func (err *internalScanError) InternalError() { // Nothing here. } diff --git a/set.go b/set.go index 4ca81b4..f686e8b 100644 --- a/set.go +++ b/set.go @@ -10,7 +10,7 @@ import ( func set(value string, argsIndex int, args ...interface{}) error { if 0 > argsIndex { - return newInternalErrorComplainer("Index value %d is less than zero.", argsIndex) + return newInternalError("Index value %d is less than zero.", argsIndex) } if lenArgs := len(args); argsIndex >= lenArgs { diff --git a/set_test.go b/set_test.go index b2fb25e..c333646 100644 --- a/set_test.go +++ b/set_test.go @@ -346,9 +346,9 @@ func TestSetFail(t *testing.T) { continue } else { switch err.(type) { - case InternalErrorComplainer: + case InternalError: if expected, actual := internalError, test.ExpectedFit; expected != actual { - t.Errorf("For test #%d, did indeed expect an error, but did not expect it to fit the \"InternalErrorComplainer\" interface, but actually did: %T.", testNumber, err) + t.Errorf("For test #%d, did indeed expect an error, but did not expect it to fit the \"InternalError\" interface, but actually did: %T.", testNumber, err) continue } case NotEnoughArgumentsComplainer: