errors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is a convenient NotFound error with a default message
	ErrNotFound = NotFound("not found")
	// ErrUnauthorized is a convenient Unauthorized error with a default message
	ErrUnauthorized = Unauthorized("unauthorized")
)

Functions

This section is empty.

Types

type BackendError

type BackendError interface {
	Error() string
	Code() int
}

BackendError is an error type which can easily be sent as a response to an API user

func Invalid

func Invalid(detail string) BackendError

Invalid creates a BackendError which indicates a problem with the user's request

func New

func New(detail string, code int) BackendError

New creates a new Err with the given detail message and error code

func NotFound

func NotFound(detail string) BackendError

NotFound creates a BackendError that indicates a requested resource was unavailable

func Unauthorized

func Unauthorized(detail string) BackendError

Unauthorized creates a BackendError which indicates a the user didn't have the correct permissions

func Unexpected

func Unexpected(detail string) BackendError

Unexpected creates a BackendError that should be returned if something happened which we didn't expect and cannot recover from

type Err

type Err struct {
	Detail    string
	ErrorCode int
}

Err is the generic backend error type

func (Err) Code

func (e Err) Code() int

Code returns the error code for this Err

func (Err) Error

func (e Err) Error() string

Jump to

Keyboard shortcuts

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