httpErrors

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrBadRequest       = "Bad request"
	ErrWrongCredentials = "Wrong Credentials"
	ErrNotFound         = "Not Found"
	ErrUnauthorized     = "Unauthorized"
	ErrForbidden        = "Forbidden"
	ErrBadQueryParams   = "Invalid query params"
)

Variables

View Source
var (
	BadRequest          = errors.New("Bad request")
	WrongCredentials    = errors.New("Wrong Credentials")
	NotFound            = errors.New("Not Found")
	Unauthorized        = errors.New("Unauthorized")
	Forbidden           = errors.New("Forbidden")
	PermissionDenied    = errors.New("Permission Denied")
	ExpiredCSRFError    = errors.New("Expired CSRF token")
	WrongCSRFToken      = errors.New("Wrong CSRF token")
	CSRFNotPresented    = errors.New("CSRF not presented")
	NotRequiredFields   = errors.New("No such required fields")
	BadQueryParams      = errors.New("Invalid query params")
	InternalServerError = errors.New("Internal Server Error")
	RequestTimeoutError = errors.New("Request Timeout")
	InvalidJWTToken     = errors.New("Invalid JWT token")
	InvalidJWTClaims    = errors.New("Invalid JWT claims")
	NoCookie            = errors.New("not found cookie header")
)

Functions

func ErrorResponse

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

Error response

Types

type RestErr

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

Rest error interface

func NewInternalServerError

func NewInternalServerError(causes interface{}) RestErr

New Internal Server Error

func NewRestError

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

New Rest Error

func NewRestErrorWithMessage

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

New Rest Error With Message

func ParseErrors

func ParseErrors(err error) RestErr

Parser of error string messages returns RestError

type RestError

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

Rest error struct

func (RestError) Causes

func (e RestError) Causes() interface{}

RestError Causes

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