errhand

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package errhand contains error handling functionality that is designed to be formatted and displayed to the user on the command line

The VerboseError interface extends error and provides a method Verbose which should give a more verbose message about an error, and it's cause.

DError is a displayable error which implements the VerboseError interface. It is formatted to be able to provide clear and concise error messaging back to the user.

Index

Constants

This section is empty.

Variables

View Source
var ErrVerboseEmpty = emptyErr{}

Functions

This section is empty.

Types

type DError

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

func NewDError

func NewDError(dispMsg, details string, cause error, printUsage bool) *DError

func (*DError) Error

func (derr *DError) Error() string

func (*DError) ShouldPrintUsage

func (derr *DError) ShouldPrintUsage() bool

func (*DError) Verbose

func (derr *DError) Verbose() string

type DErrorBuilder

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

func BuildDError

func BuildDError(dispFmt string, args ...interface{}) *DErrorBuilder

func BuildIf

func BuildIf(err error, dispFmt string, args ...interface{}) *DErrorBuilder

func (*DErrorBuilder) AddCause

func (builder *DErrorBuilder) AddCause(cause error) *DErrorBuilder

func (*DErrorBuilder) AddDetails

func (builder *DErrorBuilder) AddDetails(detailsFmt string, args ...interface{}) *DErrorBuilder

func (*DErrorBuilder) Build

func (builder *DErrorBuilder) Build() VerboseError

func (*DErrorBuilder) SetPrintUsage

func (builder *DErrorBuilder) SetPrintUsage() *DErrorBuilder

type VerboseError

type VerboseError interface {
	error
	Verbose() string
	ShouldPrintUsage() bool
}

func PanicToVError

func PanicToVError(errMsg string, f func() VerboseError) VerboseError

func VerboseErrorFromError

func VerboseErrorFromError(err error) VerboseError

Returns a verbose error using the error given. If the error given is already a VerboseError, returns it. Otherwise, creates a new VerboseError with the given error's error string.

Jump to

Keyboard shortcuts

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