errors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: GPL-3.0 Imports: 1 Imported by: 3 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	New         = errors.New
	Wrap        = errors.Wrap
	Wrapf       = errors.Wrapf
	WithStack   = errors.WithStack
	WithMessage = errors.WithMessage
)

Define an alias

View Source
var (
	ErrBadRequest              = New400Response("Request error")
	ErrInvalidParent           = New400Response("Invalid parent node")
	ErrNotAllowDeleteWithChild = New400Response("Contains children, cannot be deleted")
	ErrNotAllowDelete          = New400Response("Resources are not allowed to delete")
	ErrInvalidUserName         = New400Response("Invalid username")
	ErrInvalidPassword         = New400Response("Invalid password")
	ErrInvalidUser             = New400Response("Invalid user")
	ErrUserDisable             = New400Response("User is disabled, please contact administrator")

	ErrNoPerm          = NewResponse(401, "No access", 401)
	ErrInvalidToken    = NewResponse(9999, "Token invalidation", 401)
	ErrNotFound        = NewResponse(404, "Resource does not exist.", 404)
	ErrMethodNotAllow  = NewResponse(405, "Method is not allowed", 405)
	ErrTooManyRequests = NewResponse(429, "Request too frequently", 429)
	ErrInternalServer  = NewResponse(500, "Server error", 500)
)

Definition error

Functions

func New400Response

func New400Response(msg string) error

New400Response - Create a response error with error code 400

func New500Response

func New500Response(msg string) error

New500Response - Create a response error with error code 500

func NewResponse

func NewResponse(code int, msg string, status ...int) error

NewResponse - Create response error

func Wrap400Response

func Wrap400Response(err error, msg ...string) error

Wrap400Response - Wrong response error with package error code 400

func Wrap500Response

func Wrap500Response(err error, msg ...string) error

Wrap500Response - Wrong response error with package error code 500

func WrapResponse

func WrapResponse(err error, code int, msg string, status ...int) error

WrapResponse - Wrapper response error

Types

type ResponseError

type ResponseError struct {
	Code       int    // error code
	Message    string // wrong information
	StatusCode int    // Response status code
	ERR        error  // Response error
}

ResponseError - Define response error

func UnWrapResponse

func UnWrapResponse(err error) *ResponseError

UnWrapResponse - Unpacking response error

func (*ResponseError) Error

func (r *ResponseError) Error() string

Jump to

Keyboard shortcuts

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