httpErrors

package
v0.0.0-...-f5cdc36 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrBadRequest       = "Bad request"
	ErrAlreadyExists    = "Already exists"
	ErrNoSuchUser       = "User not found"
	ErrWrongCredentials = "Wrong Credentials"
	ErrNotFound         = "Not Found"
	ErrUnauthorized     = "Unauthorized"
	ErrForbidden        = "Forbidden"
	ErrBadQueryParams   = "Invalid query params"
	ErrRequestTimeout   = "Request Timeout"
	ErrInvalidEmail     = "Invalid email"
	ErrInvalidPassword  = "Invalid password"
	ErrInvalidField     = "Invalid field"
)

Variables

View Source
var (
	BadRequest            = Error("bad request")
	WrongCredentials      = Error("wrong Credentials")
	NotFound              = Error("not Found")
	Unauthorized          = Error("unauthorized")
	Forbidden             = Error("forbidden")
	PermissionDenied      = Error("permission Denied")
	ExpiredCSRFError      = Error("expired CSRF token")
	WrongCSRFToken        = Error("wrong CSRF token")
	CSRFNotPresented      = Error("CSRF not presented")
	NotRequiredFields     = Error("no such required fields")
	BadQueryParams        = Error("invalid query params")
	InternalServerError   = Error("internal Server Error")
	RequestTimeoutError   = Error("request Timeout")
	ExistsEmailError      = Error("user with given email already exists")
	InvalidJWTToken       = Error("invalid JWT token")
	InvalidJWTClaims      = Error("invalid JWT claims")
	NotAllowedImageHeader = Error("not allowed image header")
	NoCookie              = Error("not found cookie header")
	InvalidUUID           = Error("invalid uuid")
)

Functions

func ErrorCtxResponse

func ErrorCtxResponse(ctx echo.Context, err error) error

Error response object and status code

func ErrorResponse

func ErrorResponse(err error) (int, interface{})

Error response

Types

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type RestErr

type RestErr interface {
	Status() int
	Error() string
	Causes() interface{}
	ErrBody() RestError
}

Rest error interface

func NewBadRequestError

func NewBadRequestError(causes interface{}) RestErr

New Bad Request Error

func NewForbiddenError

func NewForbiddenError(causes interface{}) RestErr

New Forbidden Error

func NewInternalServerError

func NewInternalServerError(causes interface{}) RestErr

New Internal Server Error

func NewNotFoundError

func NewNotFoundError(causes interface{}) RestErr

New Not Found Error

func NewRestError

func NewRestError(status int, err string, causes interface{}) RestErr

New Rest Error

func NewRestErrorFromBytes

func NewRestErrorFromBytes(bytes []byte) (RestErr, error)

New Rest Error From Bytes

func NewRestErrorWithMessage

func NewRestErrorWithMessage(status int, err string, causes interface{}) RestErr

New Rest Error With Message

func NewUnauthorizedError

func NewUnauthorizedError(causes interface{}) RestErr

New Unauthorized Error

func ParseErrors

func ParseErrors(err error) RestErr

Parser of error string messages returns RestError

type RestError

type RestError struct {
	ErrCauses interface{} `json:"err_causes,omitempty"`
	ErrError  string      `json:"error,omitempty"`
	ErrStatus int         `json:"status,omitempty"`
}

Rest error struct

func (RestError) Causes

func (e RestError) Causes() interface{}

RestError Causes

func (RestError) ErrBody

func (e RestError) ErrBody() RestError

Error body

func (RestError) Error

func (e RestError) Error() string

Error Error() interface method

func (RestError) Status

func (e RestError) Status() int

Error status

Jump to

Keyboard shortcuts

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