errors

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MIT Imports: 2 Imported by: 7

README

errors

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddErrorContext

func AddErrorContext(err error, field, message string) error

AddErrorContext adds a context to an error

func Cause

func Cause(err error) error

Cause gives the original error

func GetErrorContext

func GetErrorContext(err error) map[string]string

GetErrorContext returns the error context

func Is

func Is(kind Kind, err error) bool

Is reports whether err is an *Error of the given Kind. If err is nil then Is returns false.

func Wrapf

func Wrapf(err error, msg string, args ...interface{}) error

Wrapf wraps an error with format string

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (Error) Error

func (e Error) Error() string

Error returns the mssage of a Error

func (*Error) IsZero

func (e *Error) IsZero() bool

func (Error) WithContext

func (e Error) WithContext(field, message string) error

AddErrorContext adds a context to an error

type ErrorType

type ErrorType uint

type Kind

type Kind uint
const (
	Other         Kind = iota // Unclassified error. This value is not printed in the error message.
	Invalid                   // Invalid operation for this type of item.
	Permission                // Permission denied.
	IO                        // External I/O error such as network failure.
	Exist                     // Item already exists.
	NotExist                  // Item does not exist.
	IsDir                     // Item is a directory.
	NotDir                    // Item is not a directory.
	NotEmpty                  // Directory not empty.
	Private                   // Information withheld.
	Internal                  // Internal error or inconsistency.
	CannotDecrypt             // No wrapped key for user with read access.
	Transient                 // A transient error.
	BrokenLink                // Link target does not exist.
	Timeout                   // Link target does not exist.
	Database
	BadRequest
	BadConnectString
	BadCommand
	Runtime
	Check
)

func GetType

func GetType(err error) Kind

GetType returns the error type

func (Kind) New

func (e Kind) New(msg string) Error

New creates a new Error

func (Kind) Newf

func (e Kind) Newf(msg string, args ...interface{}) Error

New creates a new Error with formatted message

func (Kind) String

func (k Kind) String() string

func (Kind) Wrap

func (e Kind) Wrap(err error, msg string) Error

Wrap creates a new wrapped error

func (Kind) Wrapf

func (e Kind) Wrapf(err error, msg string, args ...interface{}) Error

Wrap creates a new wrapped error with formatted message

Jump to

Keyboard shortcuts

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