httpErrors

package
v0.0.0-...-358e048 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrBadRequest          = "Bad request"
	ErrNotFound            = "Not Found"
	ErrUnauthorized        = "Unauthorized"
	ErrRequestTimeout      = "Request Timeout"
	ErrInvalidEmail        = "Invalid email"
	ErrInvalidPassword     = "Invalid password"
	ErrInvalidField        = "Invalid field"
	ErrInternalServerError = "Internal Server Error"
)

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")
	InternalServerError = errors.New("Internal Server Error")
)

Functions

func ErrorCtxResponse

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

ErrorCtxResponse Error response object and status code

func ErrorResponse

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

ErrorResponse Error response

func NewBadRequestError

func NewBadRequestError(ctx echo.Context, causes interface{}, debug bool) error

NewBadRequestError New Bad Request Error

func NewForbiddenError

func NewForbiddenError(ctx echo.Context, causes interface{}, debug bool) error

NewForbiddenError New Forbidden Error

func NewInternalServerError

func NewInternalServerError(ctx echo.Context, causes interface{}, debug bool) error

NewInternalServerError New Internal Server Error

func NewNotFoundError

func NewNotFoundError(ctx echo.Context, causes interface{}, debug bool) error

NewNotFoundError New Not Found Error

func NewUnauthorizedError

func NewUnauthorizedError(ctx echo.Context, causes interface{}, debug bool) error

NewUnauthorizedError New Unauthorized Error

Types

type RestErr

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

RestErr Rest error interface

func NewRestError

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

NewRestError New Rest Error

func NewRestErrorFromBytes

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

NewRestErrorFromBytes New Rest Error From Bytes

func NewRestErrorWithMessage

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

NewRestErrorWithMessage New Rest Error With Message

func ParseErrors

func ParseErrors(err error, debug bool) RestErr

ParseErrors Parser of error string messages returns RestError

type RestError

type RestError struct {
	ErrStatus  int         `json:"status,omitempty"`
	ErrError   string      `json:"error,omitempty"`
	ErrMessage interface{} `json:"message,omitempty"`
	Timestamp  time.Time   `json:"timestamp,omitempty"`
}

RestError Rest error struct

func (RestError) Causes

func (e RestError) Causes() interface{}

Causes RestError Causes

func (RestError) ErrBody

func (e RestError) ErrBody() RestError

ErrBody Error body

func (RestError) Error

func (e RestError) Error() string

Error Error() interface method

func (RestError) Status

func (e RestError) Status() int

Status Error status

Jump to

Keyboard shortcuts

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