From 87c495d123bcc8c0e480d7cff1572a01391e511f Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Thu, 20 Jun 2019 21:40:10 -0700 Subject: [PATCH] renamed "PatternSyntaxErrorComplainer" to "PatternSyntaxError" --- bad_request.go | 4 ++-- compile.go | 8 ++++---- pattern_syntax_error_complainer.go | 32 +++++++++++++++--------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bad_request.go b/bad_request.go index 38835ee..a38280c 100644 --- a/bad_request.go +++ b/bad_request.go @@ -83,7 +83,7 @@ package pathmatch // } // // Note that one can get more specific than just a BadRequest. For example: -// NotEnoughArguments, PatternSyntaxErrorComplainer, UnsupportedArgumentType, +// NotEnoughArguments, PatternSyntaxError, UnsupportedArgumentType, // and StructFieldWrongType. // // To be able to detect those more specific error types, put them BEFORE the "case pathmatch.BadRequest:" @@ -93,7 +93,7 @@ package pathmatch // if nil != err { // switch err.(type) { // -// case pathmatch.PatternSyntaxErrorComplainer: // ← Here we are detecting if the error returned was due to a syntax error, in the uncompiled pattern. Also note that it comes BEFORE the 'pathmatch.BadRequest' case; THAT IS IMPORTANT! +// case pathmatch.PatternSyntaxError: // ← Here we are detecting if the error returned was due to a syntax error, in the uncompiled pattern. Also note that it comes BEFORE the 'pathmatch.BadRequest' case; THAT IS IMPORTANT! // // fmt.Printf("The uncompiled pattern passed to pathmatch.Compile() had a syntax error in it. The error message describing the syntax error is....\n%s\n", err.Error()) // return diff --git a/compile.go b/compile.go index 16bb93c..f002a0e 100644 --- a/compile.go +++ b/compile.go @@ -13,9 +13,9 @@ const ( var ( - errMissingEndingRightBraceToMatchBeginningLeftBrace = newPatternSyntaxErrorComplainer(`Missing ending "}" (to match beginning "{").`) - errSlashInsideOfBraces = newPatternSyntaxErrorComplainer(`"/" inside of "{...}".`) - errLeftBraceInsideOfBraces = newPatternSyntaxErrorComplainer(`"{" inside of "{...}".`) + errMissingEndingRightBraceToMatchBeginningLeftBrace = newPatternSyntaxError(`Missing ending "}" (to match beginning "{").`) + errSlashInsideOfBraces = newPatternSyntaxError(`"/" inside of "{...}".`) + errLeftBraceInsideOfBraces = newPatternSyntaxError(`"{" inside of "{...}".`) ) @@ -78,7 +78,7 @@ func Compile(uncompiledPattern string) (Pattern, error) { // Match names should be unique, within a pattern. if _, ok := pattern.namesSet[bit]; ok { - return nil, newPatternSyntaxErrorComplainer("Duplicate match name: %q.", bit) + return nil, newPatternSyntaxError("Duplicate match name: %q.", bit) } diff --git a/pattern_syntax_error_complainer.go b/pattern_syntax_error_complainer.go index 94c1cea..518f495 100644 --- a/pattern_syntax_error_complainer.go +++ b/pattern_syntax_error_complainer.go @@ -6,7 +6,7 @@ import ( ) -// PatternSyntaxErrorComplainer is used to represent a specific kind of BadRequest error. +// PatternSyntaxError is used to represent a specific kind of BadRequest error. // Specifically, it represents a syntax error in the uncompiled pattern passed to the // pathmatch.Compile() func. // @@ -16,7 +16,7 @@ import ( // if nil != err { // switch err.(type) { // -// case pathmatch.PatternSyntaxErrorComplainer: // ← Here we are detecting if the error returned was due to a syntax error, in the uncompiled pattern. Also note that it comes BEFORE the 'pathmatch.BadRequest' case; THAT IS IMPORTANT! +// case pathmatch.PatternSyntaxError: // ← Here we are detecting if the error returned was due to a syntax error, in the uncompiled pattern. Also note that it comes BEFORE the 'pathmatch.BadRequest' case; THAT IS IMPORTANT! // // fmt.Printf("The uncompiled pattern passed to pathmatch.Compile() had a syntax error in it. The error message describing the syntax error is....\n%s\n", err.Error()) // return @@ -37,25 +37,25 @@ import ( // return // } // } -type PatternSyntaxErrorComplainer interface { +type PatternSyntaxError interface { BadRequest - PatternSyntaxErrorComplainer() + PatternSyntaxError() } -// internalPatternSyntaxErrorComplainer is the only underlying implementation that fits the -// PatternSyntaxErrorComplainer interface, in this library. -type internalPatternSyntaxErrorComplainer struct { +// internalPatternSyntaxError is the only underlying implementation that fits the +// PatternSyntaxError interface, in this library. +type internalPatternSyntaxError struct { msg string } -// newPatternSyntaxErrorComplainer creates a new internalPatternSyntaxErrorComplainer (struct) and -// returns it as a PatternSyntaxErrorComplainer (interface). -func newPatternSyntaxErrorComplainer(format string, a ...interface{}) PatternSyntaxErrorComplainer { +// newPatternSyntaxError creates a new internalPatternSyntaxError (struct) and +// returns it as a PatternSyntaxError (interface). +func newPatternSyntaxError(format string, a ...interface{}) PatternSyntaxError { msg := fmt.Sprintf(format, a...) - err := internalPatternSyntaxErrorComplainer{ + err := internalPatternSyntaxError{ msg:msg, } @@ -64,8 +64,8 @@ func newPatternSyntaxErrorComplainer(format string, a ...interface{}) PatternSyn // Error method is necessary to satisfy the 'error' interface (and the -// PatternSyntaxErrorComplainer interface). -func (err *internalPatternSyntaxErrorComplainer) Error() string { +// PatternSyntaxError interface). +func (err *internalPatternSyntaxError) Error() string { s := fmt.Sprintf("Bad Request: Syntax Error: %s", err.msg) return s } @@ -73,13 +73,13 @@ func (err *internalPatternSyntaxErrorComplainer) Error() string { // 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() { +func (err *internalPatternSyntaxError) BadRequest() { // Nothing here. } -// PatternSyntaxErrorComplainer method is necessary to satisfy the 'PatternSyntaxErrorComplainer' interface. +// PatternSyntaxError method is necessary to satisfy the 'PatternSyntaxError' interface. // It exists to make this error type detectable in a Go type-switch. -func (err *internalPatternSyntaxErrorComplainer) PatternSyntaxErrorComplainer() { +func (err *internalPatternSyntaxError) PatternSyntaxError() { // Nothing here. }