errors

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 3 Imported by: 2

README

errors Integration Publication Go Reference

Highly opinionated Go errors package.

Sample output

Install

go get github.com/neoxelox/errors

Usage

Check and run the example test file errors_test: go test -v.

See GoDev for further documentation.

Contribute

Feel free to contribute to this project : ) .

License

This project is licensed under the MIT License - read the LICENSE file for details.

Documentation

Overview

Package errors implements functions to deal with error handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error represent an error with traceback.

func New

func New(message string, captureStackTrace ...bool) Error

New creates a new Error with a message (can have a format) and sets to optionally capture the stack trace when raised (default is true).

func (*Error) Cause

func (self *Error) Cause(err error) *Error

Cause wraps an error into the raised Error.

func (Error) Error

func (self Error) Error() string

Error implements the Error interface.

func (*Error) Extra

func (self *Error) Extra(extra map[string]any) *Error

Extra adds extra information to the raised Error.

func (Error) Format

func (self Error) Format(format fmt.State, verb rune)

Format implements the Formatter interface: - %s: Error message - %v: First error report - %+v: All errors reports - default: Error message

func (Error) Is

func (self Error) Is(err error) bool

Is compares whether an error is Error's type.

func (Error) MarshalJSON

func (self Error) MarshalJSON() ([]byte, error)

MarshalJSON implements the JSONMarshaler interface.

func (Error) MarshalText

func (self Error) MarshalText() ([]byte, error)

MarshalText implements the TextMarshaler interface.

func (Error) Raise

func (self Error) Raise(args ...any) *Error

Raise creates a new Error instance formatting its message if needed and optionally captures its stack trace.

func (Error) Report

func (self Error) Report(all ...bool) string

Report returns a string containing all the information about the first error (including the message, stack trace, extra...) or about all errors wrapped within the Error itself (default is all).

func (*Error) Skip

func (self *Error) Skip(frames int) *Error

Skip removes n frames of the raised Error.

func (Error) String

func (self Error) String() string

String implements the Stringer interface.

func (*Error) With

func (self *Error) With(message string, args ...any) *Error

With adds more context to the raised Error's message.

Jump to

Keyboard shortcuts

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