apierrors

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBadRequestError

func IsBadRequestError(err error) bool

IsBadRequestError checks if error is of type `bad request`

func IsConflictError

func IsConflictError(err error) bool

IsConflictError checks if error is of type `conflict`

func IsForbiddenError

func IsForbiddenError(err error) bool

IsForbiddenError checks if error is of type `forbidden`

func IsInternalServerError

func IsInternalServerError(err error) bool

IsInternalServerError checks if error is of type `internal server error`

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if error is of type `not found`

func IsUnauthorizedError

func IsUnauthorizedError(err error) bool

IsUnauthorizedError checks if error is of type `unauthorized`

func IsUnknownError

func IsUnknownError(err error) bool

IsUnknownError checks if error is of type `unknown`

Types

type APIStatus

type APIStatus interface {
	Status() Status
}

func AsAPIStatus

func AsAPIStatus(err error) APIStatus

AsAPIStatus checks if the error is of type `APIStatus` and returns nil if not

type KnownReason

type KnownReason int
const (
	KnownReasonBadRequest KnownReason = iota
	KnownReasonUnauthorized
	KnownReasonForbidden
	KnownReasonNotFound
	KnownReasonConflict
	KnownReasonInternalServerError
	KnownReasonUnknown
)

type Status

type Status struct {
	Reason  KnownReason
	Code    int
	Message string
	Details string
}

type StatusError

type StatusError struct {
	ErrStatus Status
}

func NewBadRequest

func NewBadRequest(details string) *StatusError

NewBadRequest creates a new StatusError with error code 400

func NewConflict

func NewConflict(details string) *StatusError

NewConflict creates a new StatusError with error code 409

func NewForbidden

func NewForbidden(details string) *StatusError

NewForbidden creates a new StatusError with error code 403

func NewInternalServerError

func NewInternalServerError(details string) *StatusError

NewInternalServerError creates a new StatusError with error code 500

func NewNotFound

func NewNotFound(details string) *StatusError

NewNotFound creates a new StatusError with error code 404

func NewUnauthorized

func NewUnauthorized(details string) *StatusError

NewUnauthorized creates a new StatusError with error code 401

func (*StatusError) Error

func (se *StatusError) Error() string

func (*StatusError) Status

func (se *StatusError) Status() Status

Jump to

Keyboard shortcuts

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