renamed "BadRequestComplainer" to "BadRequest"

master
Charles Iliya Krempeaux 2019-06-20 21:31:53 -07:00
parent 360ca75099
commit 2a8456e3b8
5 changed files with 30 additions and 31 deletions

View File

@ -1,7 +1,6 @@
package pathmatch
// BadRequestComplainer is used to represent one of the types of errors that could be returned when
// BadRequest is used to represent one of the types of errors that could be returned when
// calling the pathmatch.Compile func, the pathmatch.Pattern.Match method, or the pathmatch.Pattern.MatchAndLoad
// method. The meaning of this type of error is that the problem was due to something whomever called the func or method did.
//
@ -9,13 +8,13 @@ package pathmatch
// a syntax error in it. Or, also for example, maybe the type of parameter passed to
// pathmatch.Pattern.Match() was of the wrong type. Etc.
//
// Example usage of BadRequestComplainer with pathmatch.Compile():
// Example usage of BadRequest with pathmatch.Compile():
//
// pattern, err := pathmatch.Compile("/fruits/{there_is_an_error_in_here/") // ← The uncompiled pattern there has an error in it.
// if nil != err {
// switch err.(type) { // ← Note that we are using a Go type-switch here.
//
// case pathmatch.BadRequestComplainer: // ← Here we are detecting if the error returned is a pathmatch.BadRequestComplainer.
// case pathmatch.BadRequest: // ← Here we are detecting if the error returned is a pathmatch.BadRequest.
//
// fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error())
// return
@ -33,16 +32,16 @@ package pathmatch
// }
//
// Somewhat continuing this example (although without the error in the uncompiled pattern), we might then
// use the pathmatch.Pattern.Match() method, which could also generate an error that fits the BadRequestComplainer
// use the pathmatch.Pattern.Match() method, which could also generate an error that fits the BadRequest
// interface.
//
// Example usage of BadRequestComplainer with pathmatch.Pattern.Match():
// Example usage of BadRequest with pathmatch.Pattern.Match():
//
// pattern, err := pathmatch.Compile("/users/{user_id}/cards/{fruit_id}")
// if nil != err {
// switch err.(type) {
//
// case pathmatch.BadRequestComplainer:
// case pathmatch.BadRequest:
//
// fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error())
// return
@ -66,7 +65,7 @@ package pathmatch
// if nil != err {
// switch err.(type) { // ← Note that we are using a Go type-switch here.
//
// case pathmatch.BadRequestComplainer: // ← Here we are detecting if the error returned is a pathmatch.BadRequestComplainer.
// case pathmatch.BadRequest: // ← Here we are detecting if the error returned is a pathmatch.BadRequest.
//
// fmt.Printf("Something you did when you called pattern.Match() caused an error. The error message was....\n%s\n", err.Error())
// return
@ -83,23 +82,23 @@ package pathmatch
// }
// }
//
// Note that one can get more specific than just a BadRequestComplainer. For example:
// Note that one can get more specific than just a BadRequest. For example:
// NotEnoughArgumentsComplainer, PatternSyntaxErrorComplainer, UnsupportedArgumentType,
// and StructFieldWrongType.
//
// To be able to detect those more specific error types, put them BEFORE the "case pathmatch.BadRequestComplainer:"
// To be able to detect those more specific error types, put them BEFORE the "case pathmatch.BadRequest:"
// in the type switch. For example:
//
// pattern, err := pathmatch.Compile("/users/{user_id}/cards/{fruit_id}")
// 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.BadRequestComplainer' case; THAT IS IMPORTANT!
// 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!
//
// 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
//
// case pathmatch.BadRequestComplainer:
// case pathmatch.BadRequest:
//
// fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error())
// return
@ -115,7 +114,7 @@ package pathmatch
// return
// }
// }
type BadRequestComplainer interface {
type BadRequest interface {
error
BadRequestComplainer()
BadRequest()
}

View File

@ -7,7 +7,7 @@ import (
type NotEnoughArgumentsComplainer interface {
BadRequestComplainer
BadRequest
NotEnoughArgumentsComplainer()
ExpectedAtLeast() int
@ -46,9 +46,9 @@ func (err *internalNotEnoughArgumentsComplainer) Error() string {
}
// BadRequestComplainer method is necessary to satisfy the 'BadRequestComplainer' interface.
// BadRequest method is necessary to satisfy the 'BadRequest' interface.
// It exists to make this error type detectable in a Go type-switch.
func (err *internalNotEnoughArgumentsComplainer) BadRequestComplainer() {
func (err *internalNotEnoughArgumentsComplainer) BadRequest() {
// Nothing here.
}

View File

@ -6,7 +6,7 @@ import (
)
// PatternSyntaxErrorComplainer is used to represent a specific kind of BadRequestComplainer error.
// PatternSyntaxErrorComplainer 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,12 +16,12 @@ 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.BadRequestComplainer' case; THAT IS IMPORTANT!
// 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!
//
// 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
//
// case pathmatch.BadRequestComplainer:
// case pathmatch.BadRequest:
//
// fmt.Printf("Something you did when you called pathmatch.Compile() caused an error. The error message was....\n%s\n", err.Error())
// return
@ -38,7 +38,7 @@ import (
// }
// }
type PatternSyntaxErrorComplainer interface {
BadRequestComplainer
BadRequest
PatternSyntaxErrorComplainer()
}
@ -71,9 +71,9 @@ func (err *internalPatternSyntaxErrorComplainer) Error() string {
}
// BadRequestComplainer method is necessary to satisfy the 'InternalErrorComplainer' interface.
// BadRequest method is necessary to satisfy the 'InternalErrorComplainer' interface.
// It exists to make this error type detectable in a Go type-switch.
func (err *internalPatternSyntaxErrorComplainer) BadRequestComplainer() {
func (err *internalPatternSyntaxErrorComplainer) BadRequest() {
// Nothing here.
}

View File

@ -8,7 +8,7 @@ import (
const structFieldWrongTypeMessagePrefix = "Bad Request: Wrong type for match "
type StructFieldWrongType interface {
BadRequestComplainer
BadRequest
MatchName() string
}
@ -39,9 +39,9 @@ func (err *internalStructFieldWrongType) Error() string {
return buffer.String()
}
// BadRequestComplainer method is necessary to satisfy the 'BadRequestComplainer' interface.
// BadRequest method is necessary to satisfy the 'BadRequest' interface.
// It exists to make this error type detectable in a Go type-switch.
func (err *internalStructFieldWrongType) BadRequestComplainer() {
func (err *internalStructFieldWrongType) BadRequest() {
// Nothing here.
}

View File

@ -5,7 +5,7 @@ import (
)
type UnsupportedArgumentType interface {
BadRequestComplainer
BadRequest
UnsupportedArgumentType()
}
@ -37,9 +37,9 @@ func (err *internalUnsupportedIndexedArgumentTypeComplainer) Error() string {
return s
}
// BadRequestComplainer method is necessary to satisfy the 'BadRequestComplainer' interface.
// BadRequest method is necessary to satisfy the 'BadRequest' interface.
// It exists to make this error type detectable in a Go type-switch.
func (err *internalUnsupportedIndexedArgumentTypeComplainer) BadRequestComplainer() {
func (err *internalUnsupportedIndexedArgumentTypeComplainer) BadRequest() {
// Nothing here.
}
@ -74,9 +74,9 @@ func (err *internalUnsupportedArgumentType) Error() string {
return fmt.Sprintf("Bad Request: Unsupported Argument Type: %s", err.msg)
}
// BadRequestComplainer method is necessary to satisfy the 'BadRequestComplainer' interface.
// BadRequest method is necessary to satisfy the 'BadRequest' interface.
// It exists to make this error type detectable in a Go type-switch.
func (err *internalUnsupportedArgumentType) BadRequestComplainer() {
func (err *internalUnsupportedArgumentType) BadRequest() {
// Nothing here.
}