Need help with emperror?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

227 Stars 14 Forks MIT License 425 Commits 5 Opened issues


The Emperor takes care of all errors personally

Services available


Need anything else?

Contributors list


Mentioned in Awesome Go

GitHub Workflow Status Codecov Go Report Card Go Version PkgGoDev FOSSA Status

The Emperor takes care of all errors personally.

Go's philosophy encourages to gracefully handle errors whenever possible, but some times recovering from an error is not.

In those cases handling the error means making the best effort to record every detail for later inspection, doing that as high in the application stack as possible.

This project provides tools to make error handling easier.

Read more about the topic here:




go get


Log errors

Logging is one of the most common target to record error events.

Emperror has two logger integrations by default: - Logur handler - Logrus handler

Annotate errors passing through an error handler

Emperror can annotate errors with details as defined in

package main

import ( "" "" )

func main() { handler := emperror.WithDetails(newHandler(), "key", "value")

err := errors.New("error")

// handled error will receive the handler details


Panics and recovers

package main

import ( "" "" )

func main() { var handler emperror.Handler = newHandler()

// Recover from panics and handle them as errors
defer emperror.HandleRecover(handler)

// nil errors will not panic

// this will panic if foo returns with a non-nil error
// useful in main func for initial setup where "if err != nil" does not make much sense


func foo() error { return errors.New("error") }

Filter errors

Sometimes you might not want to handle certain errors that reach the error handler. A common example is a catch-all error handler in a server. You want to return business errors to the client.

package main

import ( "" "" )

func main() { var handler emperror.Handler = emperror.WithFilter(newHandler(), match.Any{/any emperror.ErrorMatcher/})

// errors matching the provided matcher will not be handled



Contributions are welcome! :)

  1. Clone the repository
  2. Make changes on a new branch
  3. Run the test suite:
    ./pleasew build
    ./pleasew test
    ./pleasew gotest
    ./pleasew lint
  4. Commit, push and open a PR


The MIT License (MIT). Please see License File for more information.

FOSSA Status

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.