errors

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorEmptyLogger issued when logger received empty logger to New-method
	ErrorEmptyLogger = errors.New("options hasn't logger")
)

Functions

This section is empty.

Types

type CustomError added in v1.12.0

type CustomError interface {
	FormatResponse(ctx echo.Context)
}

type Logic

type Logic struct {
	Opts Options
}

Logic is an structure for capture and recover web-errors and panics

func New

func New(opts Options) (*Logic, error)

New creates instance of Logic structure

func (*Logic) Capture

func (c *Logic) Capture(err error, ctx echo.Context)

Capture web-errors and formatting answer

func (*Logic) Recover

func (c *Logic) Recover() echo.MiddlewareFunc

Recover is an echo-middleware to capture panics in controllers/actions and send info to sentry

type LogicError

type LogicError struct {
	Code    int
	Message string
}

LogicError used for web-controllers

func NewError

func NewError(code int, message string) *LogicError

NewError return LogicError with http-code and error message

func NewErrorf

func NewErrorf(code int, format string, a ...interface{}) *LogicError

NewErrorf return LogicError with http-code and formatted error message

func (*LogicError) Error

func (err *LogicError) Error() string

Error is an implementation of error interface

type Options

type Options struct {
	Debug  bool
	Logger logger.Logger
}

Options for creating new Logic

type Response

type Response struct {
	Error  string   `json:"error"`
	Stack  []string `json:"stack"`
	Result []string `json:"result"`
}

Response answer structure

Jump to

Keyboard shortcuts

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