errors

package
v0.0.0-...-923a9ec Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func E

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

E is a helper method for filling our Error Struct, it panics if you send anything other than an error, string, Op, or Kind

func IsKind

func IsKind(err error, kind Kind) bool

IsKind unwraps an *Error and checks if its top level kind matches

func LastMessage

func LastMessage(err error) string

LastMessage retrieves the last message on an error chain

func Messages

func Messages(err error) []string

Messages is a recursive function for building a trace of Messages

func Sentry

func Sentry(hub *sentry.Hub, err error)

Types

type Error

type Error struct {
	Sn   Sn     `json:"server,omitempty"`    // server name
	Pkg  Pkg    `json:"package,omitempty"`   // package module
	Op   Op     `json:"operation,omitempty"` // operation
	Kind Kind   `json:"kind,omitempty"`      // category of errors
	Err  error  `json:"err,omitempty"`       // the wrapped error
	Msg  string `json:"message,omitempty"`
}

Error is a custom Error struct for quickly diagnosing issues with our app

func (*Error) Error

func (e *Error) Error() string

type Kind

type Kind string

Kind is a string categorizing the error

const (
	Database               Kind = "Database"
	DatabaseResultNotFound Kind = "Database Result Not Found"
	Network                Kind = "Network"
	Type                   Kind = "Type"
)

func Kinds

func Kinds(err error) []Kind

Kinds is a recursive function for building a trace of kinds

type Op

type Op string

Op is a unique string describing a method or a function Multiple operations can construct a friendly stack tace.

func Operations

func Operations(err error) []Op

Operations is a recursive function for building a trace of operations

type Pkg

type Pkg string

Pkg is the package name our error originates from

func Packages

func Packages(err error) []Pkg

Packages is a recursive function for building a trace of packages

type Sn

type Sn string

Sn is a server name field each microservice in our network is given a unique name

func Servers

func Servers(err error) []Sn

Servers is a recursive function for building a trace of servers

Jump to

Keyboard shortcuts

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