renamed "PatternSyntaxErrorComplainer" to "PatternSyntaxError"

master
Charles Iliya Krempeaux 2019-06-20 21:40:10 -07:00
parent d669c009fe
commit 87c495d123
3 changed files with 22 additions and 22 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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.
}