erro

package
v0.0.0-...-baf4ea5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package erro provides error handling related utilities

Index

Constants

View Source
const (
	// Class 22 - Data Exception
	PqDataException             pq.ErrorClass = "22"
	PqInvalidTextRepresentation pq.ErrorCode  = "22P02"
)
View Source
const (
	// Class 23 — Integrity Constraint Violation
	PqIntegrityConstraintViolation pq.ErrorClass = "23"
	PqNotNullViolation             pq.ErrorCode  = "23502"
	PqForeignKeyViolation          pq.ErrorCode  = "23503"
	PqUniqueViolation              pq.ErrorCode  = "23505"
	PqCheckViolation               pq.ErrorCode  = "23514"
)

Variables

This section is empty.

Functions

func AsPqError

func AsPqError(err error) (*pq.Error, bool)

func Dump

func Dump(w io.Writer, err error)

Dump will dump the formatted error string (with each error in its own line) into w io.Writer

func Errorf

func Errorf(be BaseError, a ...interface{}) error

func Is

func Is(err error, target error, targets ...error) bool

Is reports whether any error in err's chain matches the target(s). Exactly the same as errors.Is, but variadic

func S1dump

func S1dump(err error) string

S1dump will return the raw error string (the entire error stack trace in one line)

func Sdump

func Sdump(err error) string

Sdump will return the formatted error string (with each error in its own line)

func Wrap

func Wrap(err error) error

Wrap will wrap an error and return a new error that is annotated with the function/file/linenumber of where Wrap() was called

Types

type BaseError

type BaseError string

func (BaseError) Error

func (e BaseError) Error() string

func (BaseError) PqCode

func (e BaseError) PqCode() pq.ErrorCode

The first five characters of the error string are assumed to be a postgres error code

type Error

type Error struct {
	BaseError BaseError
	Args      []interface{}
}

func AsError

func AsError(err error) (*Error, bool)

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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