errors

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

Overview

Package errors provides a set of tools for indicating errors.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Is is an alias for the errors.Is function. This allows this package to
	// used in place of the stdlib error package.
	Is = errors.Is

	// As is an alias for the errors.As function. This allows this package to
	// used in place of the stdlib error package.
	As = errors.As

	// New is an alias for the errors.New function. This allows this package to
	// used in place of the stdlib error package.
	New = errors.New
)
View Source
var (
	// ErrBadRequest indicates an error due to client error.
	//
	// RFC 9110, 15.5.1
	ErrBadRequest = HTTPError{
					// contains filtered or unexported fields
	}

	// ErrForbidden indicates an authentication error due insufficient
	// credentials. The client should not automatically repeat the request with
	// the same credentials. The client MAY repeat the request with new or
	// different credentials.
	//
	// RFC 9110, 15.5.4
	ErrForbidden = HTTPError{
					// contains filtered or unexported fields
	}

	// ErrNotFound indicates that the requested resource was not found.
	//
	// RFC 9110, 15.5.5
	ErrNotFound = HTTPError{
				// contains filtered or unexported fields
	}

	// ErrConflict indicates that the current request could not be completed due
	// to the current status of the requested resource. This can occur on a POST
	// request where the resource already exists.
	//
	// RFC 9110, 15.5.10
	ErrConflict = HTTPError{
				// contains filtered or unexported fields
	}

	// ErrInternal indicates that the server encountered an unexpected condition
	// that prevented it from fulfilling the request.
	//
	// RFC 9110, 15.6.1
	ErrInternal = HTTPError{
				// contains filtered or unexported fields
	}

	// ErrNotImplemented  indicates that the server does not support the
	// functionality required to fulfill the request.
	//
	// // RFC 9110, 15.6.2
	ErrNotImplemented = HTTPError{
						// contains filtered or unexported fields
	}

	// HTTPErrors maps http statuses back to manifest http errors.
	HTTPErrors = map[int]HTTPError{
		http.StatusBadRequest:          ErrBadRequest,
		http.StatusForbidden:           ErrForbidden,
		http.StatusNotFound:            ErrNotFound,
		http.StatusConflict:            ErrConflict,
		http.StatusInternalServerError: ErrInternal,
		http.StatusNotImplemented:      ErrNotImplemented,
	}
)

Functions

This section is empty.

Types

type HTTPError

type HTTPError struct {
	// contains filtered or unexported fields
}

HTTPError represents HTTP 4xx and 5xx classes of errors.

func (HTTPError) Error

func (e HTTPError) Error() string

Error returns the error message.

func (HTTPError) Status

func (e HTTPError) Status() int

Status returns the http status code of the error.

Jump to

Keyboard shortcuts

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