errutils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPError

type HTTPError struct {
	Status int    `json:"-"`
	Code   string `json:"code"`
	Reason string `json:"reason"`
}

HTTPError is a custom error type that implements the error interface.

func BadRequest

func BadRequest() *HTTPError

BadRequest is for logically incorrect requests.

func BridgeNotFound added in v1.1.0

func BridgeNotFound() *HTTPError

BridgeNotFound is returned when the required bridge does not exist.

func Conflict

func Conflict() *HTTPError

Conflict is for requests that attempt paradoxical operations, such as re-creating the same resource.

func Forbidden

func Forbidden() *HTTPError

Forbidden is for requests that do not have enough authority to execute the operation.

func InternalServerError

func InternalServerError() *HTTPError

InternalServerError is for requests that cause an unexpected misbehaviour.

func NotFound

func NotFound() *HTTPError

NotFound is for requests that try to access a non-existent resource.

func PaymentRequired

func PaymentRequired() *HTTPError

PaymentRequired is for requests that require payment completion.

func PreconditionFailed

func PreconditionFailed() *HTTPError

PreconditionFailed is for requests that do not satisfy pre-business layers of the application.

func RequestTimeout

func RequestTimeout() *HTTPError

RequestTimeout is for requests that take longer than a certain time limit to execute.

func ToHTTPError

func ToHTTPError(err interface{}) *HTTPError

ToHTTPError converts any value to an appropriate HTTPError.

func TooManyBridges added in v1.0.0

func TooManyBridges() *HTTPError

TooManyBridges is returned when there's a new bridge creation attempt but the node has reached its bridge limit.

func TooManyBridgesForClient added in v1.0.0

func TooManyBridgesForClient() *HTTPError

TooManyBridgesForClient is returned when there's a new bridge creation attempt by a client but the node has reached its bridge limit for that client.

func Unauthorized

func Unauthorized() *HTTPError

Unauthorized is for requests with invalid credentials.

func (*HTTPError) Error

func (h *HTTPError) Error() string

Error provides the reason behind the error, which is usually human-readable. If the reason is absent, it provides the error code instead.

func (*HTTPError) WithReasonError added in v1.0.0

func (h *HTTPError) WithReasonError(reason error) *HTTPError

WithReasonError is a chainable method to set the reason of the HTTPError.

This accepts the reason as an error.

func (*HTTPError) WithReasonString added in v1.0.0

func (h *HTTPError) WithReasonString(reason string) *HTTPError

WithReasonString is a chainable method to set the reason of the HTTPError.

This accepts the reason as a string.

Jump to

Keyboard shortcuts

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