oops

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(err error) error

Err builds annotated error instance from any error value

func Handling

func Handling(ctx *gin.Context, err error)

Handling handles an error by setting a message and a response status code

func HandlingGRPC

func HandlingGRPC(err error) error

HandlingGRPC handle an error by defining HTTP response body and code

func Wrap

func Wrap(err error, message string) error

Wrap wraps an error adding an information message

Types

type Error

type Error struct {
	Code       int      `json:"code"`
	Message    string   `json:"message"`
	Trace      []string `json:"-"`
	Err        error    `json:"-"`
	StatusCode int      `json:"-"`
}

Error defines the properties for a basic error response

func New

func New(msg string) *Error

New creates and returns new normalized `Error` instance.

func NewError

func NewError(message string, statusCode int) *Error

NewError creates and returns new normalized `Error` instance.

func NotFoundError

func NotFoundError(message string) *Error

NotFoundError creates and returns 404 `Error`.

func (*Error) Error

func (e *Error) Error() string

Error makes it compatible with the `error` interface

func (*Error) IsHandled

func (e *Error) IsHandled() bool

IsHandled check if error has already been handled

Jump to

Keyboard shortcuts

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