utils

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest            = errors.New("bad request")
	ErrWrongCredentials      = errors.New("wrong credentials")
	ErrNotFound              = errors.New("not found")
	ErrUnauthorized          = errors.New("unauthorized")
	ErrForbidden             = errors.New("forbidden")
	ErrPermissionDenied      = errors.New("permission denied")
	ErrExpiredCSRFError      = errors.New("expired CSRF token")
	ErrWrongCSRFToken        = errors.New("wrong CSRF token")
	ErrCSRFNotPresented      = errors.New("CSRF not presented")
	ErrNotRequiredFields     = errors.New("no such required fields")
	ErrBadQueryParams        = errors.New("invalid query params")
	ErrInternalServerError   = errors.New("internal server error")
	ErrRequestTimeoutError   = errors.New("request timeout")
	ErrExistsEmailError      = errors.New("user with given email already exists")
	ErrInvalidJWTToken       = errors.New("invalid JWT token")
	ErrInvalidJWTClaims      = errors.New("invalid JWT claims")
	ErrNotAllowedImageHeader = errors.New("not allowed image header")
	ErrNoCookie              = errors.New("not found cookie header")
	ErrUnprocessableEntity   = errors.New("unprocessable entity")
	ErrAuthenticationFailed  = errors.New("authentication vailed")
)

Functions

func CompactJSON added in v1.0.2

func CompactJSON(data []byte) string

func GetReqID added in v1.0.5

func GetReqID(ctx context.Context) string

GetReqID get request id from echo context

func PanicIfNeeded added in v1.0.5

func PanicIfNeeded(err interface{})

PanicIfNeeded is panic if needed

func ParseHttpError added in v1.0.2

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

Parse Http Error

Types

type HttpErr added in v1.0.2

type HttpErr interface {
	Status() int
	Error() string
	Details() interface{}
}

HttpErr interface

func NewAuthenticationFailedError added in v1.0.2

func NewAuthenticationFailedError(details interface{}) HttpErr

New Authentication Failed Error

func NewBadRequestError added in v1.0.2

func NewBadRequestError(details interface{}) HttpErr

New Bad Request Error

func NewForbiddenError added in v1.0.2

func NewForbiddenError(details interface{}) HttpErr

New Forbidden Error

func NewHttpError added in v1.0.2

func NewHttpError(status int, err string, details interface{}) HttpErr

New Http Error

func NewInternalServerError added in v1.0.2

func NewInternalServerError(details interface{}) HttpErr

New Internal Server Error

func NewInvalidInputError added in v1.0.2

func NewInvalidInputError(errs validation.Errors) HttpErr

New Invalid Input Error - Validation

func NewNotFoundError

func NewNotFoundError(details interface{}) HttpErr

New Not Found Error

func NewUnauthorizedError added in v1.0.2

func NewUnauthorizedError(details interface{}) HttpErr

New Unauthorized Error

func NewUnprocessableEntityError added in v1.0.2

func NewUnprocessableEntityError(details interface{}) HttpErr

New Unprocessable Entity Error

type HttpError added in v1.0.2

type HttpError struct {
	ErrStatus  int         `json:"status"`
	ErrError   string      `json:"error"`
	ErrDetails interface{} `json:"details"`
}

HttpError struct

func (HttpError) Details added in v1.0.2

func (e HttpError) Details() interface{}

HttpError Details

func (HttpError) Error added in v1.0.2

func (e HttpError) Error() string

Error Error() interface method

func (HttpError) Status added in v1.0.2

func (e HttpError) Status() int

Error status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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