errors

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlameUser describes the error was caused by user and the status code shall blame the user
	BlameUser = http.StatusBadRequest
	// BlameServer describes the error was caused by server internally and therefore shall blame the server
	BlameServer = http.StatusInternalServerError
)

Variables

View Source
var (
	// ErrInvalidServer describes an error in which a malformed `server` provided
	ErrInvalidServer = New("InvalidServer", "malformed `server` provided", BlameUser)
)

Functions

This section is empty.

Types

type Error

type Error struct {
	Type    string      `json:"type"`
	Details interface{} `json:"details"`
	Blame   int         `json:"-"`
}

Error describes an error with several metadata to describe such error

func New

func New(typ string, details interface{}, blame int) *Error

New creates a new Error instance

func (*Error) Wrapped

func (e *Error) Wrapped() *WrappedError

Wrapped returns a WrappedError consists of current Error

type WrappedError

type WrappedError struct {
	Error *Error `json:"error"`
}

WrappedError wraps Error for the client to be able to easily distinguish successful responses and error responses

Jump to

Keyboard shortcuts

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