Package erorr implements tools to create and manipulate errors, for the Go programming-language (golang).
Find a file
2026-03-09 19:58:17 -07:00
doc.go docs 2025-12-21 11:30:20 -08:00
error.go docs 2025-12-21 11:33:13 -08:00
errorf.go wrapped errors 2025-12-20 13:59:47 -08:00
errorf_examples_test.go errors messages 2026-03-09 19:58:17 -07:00
errors.go erorr.Errors 2026-01-02 16:19:47 -08:00
go.mod errors messages 2026-03-09 19:58:17 -07:00
go.sum errors messages 2026-03-09 19:58:17 -07:00
is.go erorr.Is() 2025-12-19 20:21:23 -08:00
is_test.go erorr.Is() 2025-12-19 20:21:23 -08:00
LICENSE changelog.ca -> reiver.link 2024-08-01 16:33:53 -07:00
README.md docs 2025-12-20 09:00:09 -08:00
stampederror.go docs 2025-12-21 11:45:26 -08:00
wrap.go wrap 2025-12-21 11:58:51 -08:00
wrap_examples_test.go errors messages 2026-03-09 19:58:17 -07:00
wrappederror.go errors messages 2026-03-09 19:58:17 -07:00
wrappederrors.go errors messages 2026-03-09 19:58:17 -07:00

go-erorr

Package erorr provides tools for creating and manipulating errors, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-erorr

GoDoc

History

This package's origin goes back to July 23rd, 2015 and before.

It started off as package manyerrors — which provided a way to combined multiple errors into a single error. Later package fck was created — which provided a way to create const errors (rather than having to use var). Eventually, package fck was renamed to package erorr — and later the concepts from package manyerrors were merged into it. Later, package erorr provides tool for creating error annotations and contextual errors. And, finally, package erorr switched to using Unwrap() error and Unwrap() []error methods to match the conventions in the built-in Golang "errors" package.

Example

Here are some examples.

Core Errors

Create your core errors with source-code similar to the following:

const (
	ErrNilReceiver = erorr.Error("nil receiver")
	ErrNotFound    = erorr.Error("not found")
	ErrUndefined   = erorr.Error("undefined")
)

Notice that a const was used (rather than a var).

Annotated Errors

Create an annotated error with source-code similar to the following:

if nil != err {
	return erorr.Wrap(err, "API request failed.",
		field.String("request-uri", requestURI),
		field.String("service", "monitor"),
	)
}

Contextual Errors

Create a contextual error with source-code similar to the following:

if nil != err {
	return erorr.Wrap("API request failed.",
		field.String("request-uri", requestURI),
		field.String("service", "monitor"),
	)
}

Note that erorr.Stamp() is similar to erorr.Wrap(), with the difference being that, erorr.Stamp() does not wrap another error.

Errorf

The function erorr.Errorf() is also available. For example:

if !isValidID(id) {
	return erorr.Errorf("bad value for id %q", id)
}

Or also, for example:

if nil != err {
	return erorr.Errorf("Uh oh, something bad happened to %s: %w", service, err)
}

Note that a different because this package's erorr.Errorf() function and the fmt.Errorf() in the built-in Go "fmt" package is that the error returned from this package's erorr.Errorf() function will include a call-trace and other annotation and contextual information.

Import

To import package erorr use import code like the follownig:

import "codeberg.org/reiver/go-erorr"

Installation

To install package erorr do the following:

GOPROXY=direct go get https://codeberg.org/reiver/go-erorr

Author

Package erorr was written by Charles Iliya Krempeaux