goerror

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 4 Imported by: 1

README

goerror

Its is a super-small super-light struct that I use in most of my projects to wrap errors. It is a little bit unorthodox, since it features some chaining methods, but I think it is very handy.

Each error has a unique ID, and a message. The ID is used to identify the error, e.g. with errors.Is(). The message is used to display a user message.

This originated from one of my web projects. Error.Message is thought as return value for the user, the actual error is stored in Error.Err. Therefore, Error.MarshalJSON() will return the message, and Error.Id, but not the actual error.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(code, message string) traceableErrorImpl

Types

type TraceableError

type TraceableError interface {
	error
	Unwrap() error
	Is(error) bool
	MarshalJSON() ([]byte, error)
	WithMessage(string) TraceableError
	WithError(error) TraceableError
	WithOrigin() TraceableError
	GetMessage() string
}

Jump to

Keyboard shortcuts

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