From 2a8456e3b8b695dab46e527ba81e91722f61402a Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Thu, 20 Jun 2019 21:31:53 -0700 Subject: [PATCH] renamed "BadRequestComplainer" to "BadRequest" --- bad_request_complainer.go | 27 +++++++++++++-------------- not_enough_arguments_complainer.go | 6 +++--- pattern_syntax_error_complainer.go | 12 ++++++------ struct_field_wrong_type.go | 6 +++--- unsupported_argument_type.go | 10 +++++----- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/bad_request_complainer.go b/bad_request_complainer.go index 5dc41bd..4361271 100644 --- a/bad_request_complainer.go +++ b/bad_request_complainer.go @@ -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() } diff --git a/not_enough_arguments_complainer.go b/not_enough_arguments_complainer.go index d53b1af..21d5f46 100644 --- a/not_enough_arguments_complainer.go +++ b/not_enough_arguments_complainer.go @@ -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. } diff --git a/pattern_syntax_error_complainer.go b/pattern_syntax_error_complainer.go index d197478..e422911 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 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. } diff --git a/struct_field_wrong_type.go b/struct_field_wrong_type.go index 514a03a..3d01c7e 100644 --- a/struct_field_wrong_type.go +++ b/struct_field_wrong_type.go @@ -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. } diff --git a/unsupported_argument_type.go b/unsupported_argument_type.go index 6b5013c..ec8e4ec 100644 --- a/unsupported_argument_type.go +++ b/unsupported_argument_type.go @@ -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. }