verror

package
v1.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMongoDelete = errors.New("no delete document")

ErrMongoDelete represents an delete error in mongo case

View Source
var ErrMongoUpdate = errors.New("no updated document")

ErrMongoUpdate represents an update error in mongo case

Functions

func BadRequest added in v1.0.1

func BadRequest(message string, body ...interface{}) error

BadRequest creates an echo.HTTPError with the status http.StatusBadRequest

func Conflict added in v1.0.1

func Conflict(message string, body ...interface{}) error

Conflict creates an echo.HTTPError with the status http.StatusConflict

func HTTPErrorHandler added in v1.0.1

func HTTPErrorHandler(err error, c echo.Context)

HTTPErrorHandler handles echo.HTTPError and return the correct response.

func InternalServerError added in v0.1.16

func InternalServerError(err error) error

InternalServerError creates an echo.HTTPError with the status http.StatusInternalServerError

func JSONValidate added in v0.1.15

func JSONValidate(c echo.Context, i interface{}) error

JSONValidate validates a json bind in echo.Context. The interface i is used for validation. If the c.Bind(i) or the validation returns errors the function return an APIError.

func Mongo added in v0.1.16

func Mongo(err error, model string) error

func MongoCreate added in v0.1.16

func MongoCreate(err error, model string) error

func MongoDelete added in v0.1.16

func MongoDelete(err error, model string) error

func MongoDeleteErr

func MongoDeleteErr(err error, result *mongo.DeleteResult) error

MongoDeleteErr helper for handling delete errors

func MongoGet added in v0.1.16

func MongoGet(err error, model string) error

func MongoList added in v0.1.16

func MongoList(err error, model string) error

func MongoUpdate added in v0.1.16

func MongoUpdate(err error, model string) error

func MongoUpdateErr

func MongoUpdateErr(err error, result *mongo.UpdateResult) error

MongoUpdateErr helper for handling update errors

func NotFound added in v1.0.1

func NotFound(message string, body ...interface{}) error

NotFound creates an echo.HTTPError with the status http.StatusNotFound

Types

type ErrJSONResponse added in v1.0.1

type ErrJSONResponse struct {
	JSONError JSONError
}

func (*ErrJSONResponse) Error added in v1.0.1

func (e *ErrJSONResponse) Error() string

type JSONError added in v0.1.15

type JSONError struct {
	Errors []string `json:"errors"`
}

JSONError represents a json validation error. Used om return of JSONErrorResponse.

func NewJSONError added in v1.0.1

func NewJSONError(err error) (jsonErr *JSONError)

JSONErrorResponse creates a response for json validation error.

func (*JSONError) Error added in v0.1.15

func (i *JSONError) Error() string

type JSONValidator added in v0.1.15

type JSONValidator struct {
	Validator *validator.Validate
}

JSONValidator represents the json validator struct.

func (*JSONValidator) Validate added in v0.1.15

func (cv *JSONValidator) Validate(i interface{}) error

Validate extend JSONValidator with Validate function.

type Response added in v1.0.1

type Response struct {
	Status  int         `json:"-"`
	Message string      `json:"message"`
	Body    interface{} `json:"body,omitempty"`
	Coll    string      `json:"collection,omitempty"`
	Model   string      `json:"model,omitempty"`
}

Response represents an response json in case of an error.

Jump to

Keyboard shortcuts

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