serror

package
v0.0.0-...-ca83fcd Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Service string

Service the service name

Functions

func Is

func Is(err error, code int) bool

Checks if the error is an service error of the given code

func Wrapper

func Wrapper(fn func(err error) *Serr)

Wrapper are used to wrap specific errors into service errors please do not call Wrap or Wrapc in the implemented function

Types

type Serr

type Serr struct {
	Code   int    `json:"code"`
	Key    string `json:"key"`
	Srv    string `json:"service,omitempty"`
	Msg    string `json:"message,omitempty"`
	Origin string `json:"origin,omitempty"`
}

Serr error model

func BadRequest

func BadRequest(err error, args ...string) *Serr

BadRequest bad request error

func Forbidden

func Forbidden(err error, args ...string) *Serr

Forbidden forbidden error

func InternalServerError

func InternalServerError(err ...error) *Serr

InternalServerError not found error

func New

func New(code int, args ...string) *Serr

New creates an error

func NotFound

func NotFound(typ string, id string, err ...error) *Serr

NotFound not found error

func Unauthorized

func Unauthorized(err error, args ...string) *Serr

Unauthorized unauthorized error

func Wrap

func Wrap(err error, args ...string) *Serr

Wrap wraps an error

func Wrapc

func Wrapc(err error, code int, args ...string) *Serr

Wrapc wraps an error (with code)

func (*Serr) Error

func (e *Serr) Error() string

Error returns the error

Jump to

Keyboard shortcuts

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