errnie

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: Unlicense Imports: 9 Imported by: 18

README

errnie

A specialized error handling and logging package to suit my personal preferences for improving developer ergonomics.

Quality Gate Status Bugs Code Smells Lines of Code Coverage Technical Debt Maintainability Rating Vulnerabilities Security Rating Reliability Rating

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Breakpoints

func Breakpoints(value bool)

Breakpoints behavior turned on or off.

func Debugging

func Debugging(value bool)

Debugging behavior turned on or off.

func Debugs

func Debugs(msgs ...any) []byte

Debugs is syntactic sugar to call the Debug method on a Logger interface.

func Errors

func Errors(msgs ...any)

Errors is syntactic sugar to call the Warning method on a Logger interface.

func Handles

func Handles(err error) error

func IOError

func IOError(err error) bool

IOError is a specialized error wrapper for IO related errors.

It handles situations where EOF errors should be treated as nil. By returning a boolean value it can be nicely composed within if statements as per the example below.

```

if err := SomeIOTask(); errnie.IOError(err) {
	return err
}

```

func Informs

func Informs(msgs ...any)

Informs is syntactic sugar to call the Info method on a Logger interface.

func Inspects

func Inspects(msgs ...any)

Inspects is syntactic sugar to dump the structure and values of objects with arbitrary complexity to logger output channels.

func Kills

func Kills(err error)

func NewError

func NewError(err error) error

NewError instantiates a new errnie Error and returns a pointer to it.

func Quiet

func Quiet(outputs ...io.Writer)

func Success

func Success(msgs ...any)

Success is syntactic sugar to call the Info method on a Logger interface.

func Trace

func Trace()

func Tracing

func Tracing(value bool)

Tracing behavior turned on or off.

func Trap

func Trap()

Trap will execute a breakpoint trap if the relevant configuration parameter is set to `true`.

func Warns

func Warns(msgs ...any)

Warns is syntactic sugar to call the Warning method on a Logger interface.

Types

type Context

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

Context wraps all state and behavior errnie needs to act as an error handler, logger, and tracer.

func Ctx

func Ctx() *Context

Ctx returns the ambient context for use of its io.ReadWriteCloser interface implementation.

func New

func New() *Context

New constructs and instantiates the ambient context available to errnie internally. Application code can access the instance through the publicly exposed functions.

func (*Context) Close

func (ctx *Context) Close() error

Close implements the io.Closer interface.

It is a wrapper around the underlying file handle Close method.

func (*Context) Write

func (ctx *Context) Write(p []byte) (n int, err error)

Write implements the io.Writer interface.

It is a wrapper around the underlying file MultiWriter Write method.

type Error

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

Error is a custom wrapping around Go errors keeping errnie errors fully compatible with conventions.

func (*Error) Error

func (ee *Error) Error() string

Error implements the Go error interface by returning the error message.

type ErrorContext

type ErrorContext uint

ErrorContext adds a strongly typed context to the error.

const (
	// NIL represents no error was generated.
	NIL ErrorContext = iota
	// INTEGRITY represents a failure to verify the integrity of data.
	INTEGRITY
	// VALIDATION represents an error during validation of a value.
	VALIDATION
	// CONVERSION represents an error while converting a value type.
	CONVERSION
	// IOERROR represents a generic IO operation failure.
	IOERROR
	// UNKNOWN represents an error with unknown cause.
	UNKNOWN
)

type Presenter

type Presenter struct {
	Level   string `json:"level"`
	Message string `json:"message"`
}

type Tracer

type Tracer struct {
}

Jump to

Keyboard shortcuts

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