errutils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 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 {
	StatusCode int      `json:"status_code"`
	CustomCode string   `json:"custom_code"`
	Errors     []string `json:"errors"`
}

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

func AccountAlreadyExists

func AccountAlreadyExists() *HTTPError

AccountAlreadyExists is for requests that want to duplicate an existing account.

func AccountIsInUse

func AccountIsInUse() *HTTPError

AccountIsInUse is for requests that want to delete an account that is being used by transactions.

func AccountNotFound

func AccountNotFound() *HTTPError

AccountNotFound is for requests that want to access a non-existent account.

func BadRequest

func BadRequest() *HTTPError

BadRequest is for logically incorrect requests.

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 TransactionNotFound

func TransactionNotFound() *HTTPError

TransactionNotFound is for requests that want to access a non-existent transaction.

func Unauthorized

func Unauthorized() *HTTPError

Unauthorized is for requests with invalid credentials.

func (*HTTPError) AddErrors

func (h *HTTPError) AddErrors(errors ...error) *HTTPError

AddErrors is a chainable method to add error messages to the HTTPError.

func (*HTTPError) AddMessages

func (h *HTTPError) AddMessages(message ...string) *HTTPError

AddMessages is a chainable method to add string messages to the HTTPError.

func (*HTTPError) Error

func (h *HTTPError) Error() string

Jump to

Keyboard shortcuts

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