kerrors

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MPL-2.0 Imports: 5 Imported by: 39

README

kerrors

errors with context

import via xorkevin.dev/kerrors

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...ErrorOpt) error

New creates a new *Error

func WithKind

func WithKind(err error, kind error, msg string) error

WithKind returns an error wrapped by an *Error with a Kind and Message

func WithMsg

func WithMsg(err error, msg string) error

WithMsg returns an error wrapped by an *Error with a Message

Types

type Error

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

Error is an error with context

func (*Error) Error

func (e *Error) Error() string

Error implements error and recursively prints wrapped errors

func (*Error) ErrorMsg added in v0.1.3

func (e *Error) ErrorMsg() string

ErrorMsg returns the error message

func (*Error) Inner

func (e *Error) Inner() error

Inner returns the inner wrapped error

func (*Error) Kind

func (e *Error) Kind() error

Kind returns the error kind

func (*Error) Unwrap

func (e *Error) Unwrap() []error

Unwrap implements errors.Unwrap

func (*Error) WriteError

func (e *Error) WriteError(b io.Writer)

WriteError implements ErrorWriter

type ErrorMsger added in v0.1.3

type ErrorMsger interface {
	ErrorMsg() string
}

ErrorMsger returns the error message

type ErrorOpt

type ErrorOpt = func(e *Error)

ErrorOpt is an error options function used by New

func OptInner

func OptInner(inner error) ErrorOpt

OptInner returns an ErrorOpt that sets Error Inner

func OptKind

func OptKind(kind error) ErrorOpt

OptKind returns an ErrorOpt that sets Error Kind

func OptMsg

func OptMsg(msg string) ErrorOpt

OptMsg returns an ErrorOpt that sets Error Message

func OptSkip added in v0.1.1

func OptSkip(skip int) ErrorOpt

OptSkip returns an ErrorOpt that increments Error skip by a number of frames for stack trace

type ErrorWriter

type ErrorWriter interface {
	WriteError(b io.Writer)
}

ErrorWriter writes errors to an io.Writer

type StackStringer added in v0.1.2

type StackStringer interface {
	StackString() string
}

StackStringer returns a stacktrace string

type StackTrace

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

StackTrace is an error stack trace

func NewStackTrace

func NewStackTrace(skip int) *StackTrace

NewStackTrace creates a new *StackTrace

func (*StackTrace) Error

func (e *StackTrace) Error() string

Error implements error and prints the stack trace

func (*StackTrace) PC added in v0.1.5

func (e *StackTrace) PC() []uintptr

func (*StackTrace) StackString

func (e *StackTrace) StackString() string

StackString implements StackStringer and formats each frame of the stack trace with the default format

func (*StackTrace) WriteError

func (e *StackTrace) WriteError(b io.Writer)

WriteError implements ErrorWriter and writes the stack trace

Jump to

Keyboard shortcuts

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