...

Source file src/github.com/jarcoal/httpmock/internal/error.go

Documentation: github.com/jarcoal/httpmock/internal

     1  package internal
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  // NoResponderFound is returned when no responders are found for a
     9  // given HTTP method and URL.
    10  var NoResponderFound = errors.New("no responder found") // nolint: revive
    11  
    12  // ErrorNoResponderFoundMistake encapsulates a NoResponderFound
    13  // error probably due to a user error on the method or URL path.
    14  type ErrorNoResponderFoundMistake struct {
    15  	Kind      string // "method" or "URL"
    16  	Orig      string // original wrong method/URL, without any matching responder
    17  	Suggested string // suggested method/URL with a matching responder
    18  }
    19  
    20  var _ error = (*ErrorNoResponderFoundMistake)(nil)
    21  
    22  // Unwrap implements the interface needed by errors.Unwrap.
    23  func (e *ErrorNoResponderFoundMistake) Unwrap() error {
    24  	return NoResponderFound
    25  }
    26  
    27  // Error implements error interface.
    28  func (e *ErrorNoResponderFoundMistake) Error() string {
    29  	return fmt.Sprintf("%[1]s for %[2]s %[3]q, but one matches %[2]s %[4]q",
    30  		NoResponderFound,
    31  		e.Kind,
    32  		e.Orig,
    33  		e.Suggested,
    34  	)
    35  }
    36  

View as plain text