kerr

package module
v0.0.0-...-776b4fd Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: MIT Imports: 5 Imported by: 6

README

kerr

Documentation

Overview

Package kerr is an error with a unique ID

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(id string, format string, args ...interface{}) error

New creates a new kerr.Struct

func Source

func Source(e error) error

Source gets the error at the bottom of the error stack. This can't be a method on kerr.Struct because it needs to return the whole error when called on an error that embeds kerr.Struct

func Wrap

func Wrap(id string, inner error, descriptionFormatAndArgs ...interface{}) error

Wrap wraps an error in a kerr.Struct

Types

type Interface

type Interface interface {
	ErrorId() string
	ErrorStack() []string
	ErrorInner() error
}

type Struct

type Struct struct {
	// Unique ID for this error - used to identify this error in tests
	Id string
	// The inner error. Nil if this is the source error.
	Inner error
	// Path of the file that this error occurred in
	File string
	// Line number of the source where this error occurred
	Line int
	// Package path where the error occurred
	Package string
	// Function name where this error occurred
	Function string
	// Description is a description of the error if there is no inner error, or else
	// a description of the fucntion that returned the inner error
	Description string
	// Array of unique IDs of the error stack
	Stack []string
}

Struct is an error with a unique Id.

func (Struct) Error

func (e Struct) Error() string

Error returns a string of the error

func (Struct) ErrorId

func (e Struct) ErrorId() string

ErrorId returns the unique id of the error

func (Struct) ErrorInner

func (e Struct) ErrorInner() error

ErrorInner returns the inner error

func (Struct) ErrorStack

func (e Struct) ErrorStack() []string

ErrorStack returns the error id stack

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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