clienterror

package
v0.0.0-...-2caf503 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAccessForbiddenError

func IsAccessForbiddenError(err error) bool

IsAccessForbiddenError checks whether the error is an HTTP 403 error.

func IsBadRequestError

func IsBadRequestError(err error) bool

IsBadRequestError checks whether the error is an HTTP 400 error.

func IsCertificateHostnameError

func IsCertificateHostnameError(err error) bool

IsCertificateHostnameError checks whether the error represents a x509.HostnameError

func IsCertificateInvalidError

func IsCertificateInvalidError(err error) bool

IsCertificateInvalidError checks whether the error represents a x509.UnknownAuthorityError

func IsCertificateSignedByUnknownAuthorityError

func IsCertificateSignedByUnknownAuthorityError(err error) bool

IsCertificateSignedByUnknownAuthorityError checks whether the error represents a x509.UnknownAuthorityError

func IsConflictError

func IsConflictError(err error) bool

IsConflictError checks whether the error is an HTTP 409 error.

func IsInternalServerError

func IsInternalServerError(err error) bool

IsInternalServerError checks whether the error is an HTTP 500 error.

func IsMalformedResponse

func IsMalformedResponse(err error) bool

IsMalformedResponse checks whether the error is "Malformed response", which can mean several things.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks whether the error is an HTTP 404 error.

func IsServiceUnavailableError

func IsServiceUnavailableError(err error) bool

IsServiceUnavailableError checks whether the error is an HTTP 503 error.

func IsUnauthorizedError

func IsUnauthorizedError(err error) bool

IsUnauthorizedError checks whether the error is an HTTP 401 error.

Types

type APIError

type APIError struct {
	// HTTPStatusCode holds the HTTP response status code, if there was any.
	HTTPStatusCode int

	// OriginalError is the original error object which should contain
	// type-specific details.
	OriginalError error

	// ErrorMessage is a short, user-friendly error message we generate for
	// presenting details to the end user.
	ErrorMessage string

	// ErrorDetails is a longer text we MAY set additionally to help the user
	// understand and maybe solve the problem.
	ErrorDetails string

	// URL is the URL called with the request.
	URL string

	// HTTPMethod is the HTTP method used.
	HTTPMethod string

	// IsTimeout will be true if our error was a timeout error.
	IsTimeout bool

	// IsTemporary will be true if we think that a retry will help.
	IsTemporary bool
}

APIError is our structure to carry all error information we care about from the api client to the CLI.

func New

func New(err error) *APIError

New creates a new APIError based on all the incoming error details. One goal here is to let handlers deal with only one type of error.

func (APIError) Error

func (ae APIError) Error() string

Error returns the error message and allows us to use our APIError as an error type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL