srverr

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package zqe provides a mechanism to create or wrap errors with information that will aid in reporting them to users and returning them to api callers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func E

func E(args ...interface{}) error

Function E generates an error from any mix of:

  • a Kind
  • an existing error
  • a string and optional formatting verbs, like fmt.Errorf (including support for the `%w` verb).

The string & format verbs must be last in the arguments, if present.

func ErrConflict

func ErrConflict(args ...interface{}) error

func ErrExists

func ErrExists(args ...interface{}) error

func ErrForbidden

func ErrForbidden(args ...interface{}) error

func ErrInvalid

func ErrInvalid(args ...interface{}) error

func ErrNoCredentials

func ErrNoCredentials(args ...interface{}) error

func ErrNotFound

func ErrNotFound(args ...interface{}) error

func ErrOther

func ErrOther(args ...interface{}) error

func IsConflict

func IsConflict(err error) bool

func IsExists

func IsExists(err error) bool

func IsForbidden

func IsForbidden(err error) bool

func IsInvalid

func IsInvalid(err error) bool

func IsKind

func IsKind(err error, k Kind) bool

IsKind returns true if the provided error can be unwrapped as a *Error and if *Error.Kind matches the provided Kind

func IsNoCredentials

func IsNoCredentials(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsOther

func IsOther(err error) bool

func RecoverError

func RecoverError(r interface{}) error

Types

type Error

type Error struct {
	Kind Kind
	Err  error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Message

func (e *Error) Message() string

Message returns just the Err.Error() string, if present, or the Kind string description. The intent is to allow zqe users a way to avoid embedding the Kind description as happens with Error().

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Kind

type Kind int

A Kind represents a class of error. API layers will typically convert these into a domain specific error representation; for example, an HTTP handler can convert these to HTTP status codes.

const (
	Other Kind = iota
	Conflict
	Exists
	Forbidden
	Invalid
	NoCredentials
	NotFound
)

func (Kind) String

func (k Kind) String() string

Jump to

Keyboard shortcuts

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