httpErrors

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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