microerror

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 3,054

README

godoc CircleCI

microerror

Go library to facilitate error handling.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause is here only for backward compatibility purposes and should not be used.

NOTE: Use errors.Is/errors.As instead.

func JSON added in v0.2.0

func JSON(err error) string

JSON prints the error with enriched information in JSON format. Enriched information includes:

  • All fields from Error type.
  • Error stack.

The rendered JSON can be unmarshalled with JSONError type.

func Mask

func Mask(err error) error

func Maskf

func Maskf(err *Error, f string, v ...interface{}) error

func Pretty added in v0.2.1

func Pretty(err error, stackTrace bool) string

Types

type Error

type Error struct {
	Desc string `json:"desc,omitempty"`
	Docs string `json:"docs,omitempty"`
	Kind string `json:"kind"`
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) GoString

func (e *Error) GoString() string

GoString is here for backward compatibility.

NOTE: Use JSON(err) instead of Printf("%#v", err).

type JSONError added in v0.2.0

type JSONError struct {
	*Error `json:",inline"`

	Annotation string       `json:"annotation,omitempty"`
	Stack      []StackEntry `json:"stack,omitempty"`
}

type StackEntry added in v0.2.0

type StackEntry struct {
	File string  `json:"file"`
	Line int     `json:"line"`
	PC   uintptr `json:"-"`
}

Jump to

Keyboard shortcuts

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