Skip to content
/ erero Public

erero is a simple error-handling package designed to log errors along with their context and location.

License

Notifications You must be signed in to change notification settings

yyle88/erero

Repository files navigation

GitHub Workflow Status (branch) GoDoc Coverage Status Supported Go Versions GitHub Release Go Report Card

erero

erero is a simple error-handling package designed to log errors along with their context and location.

package name erero doesn't conflict with Go's standard errors package or other popular libraries like github.com/pkg/errors or github.com/go-kratos/kratos/v2/errors.

CHINESE README

中文说明

Installation

go get github.com/yyle88/erero

Example Usage

package main

import (
	"fmt"
	"math/rand/v2"

	"github.com/yyle88/erero"
)

func sub1() error {
	if rand.IntN(100) < 30 {
		return erero.New("wrong")
	}
	return nil
}

func sub2() error {
	if num := rand.IntN(100); num < 20 {
		return erero.Errorf("wrong num=%d", num)
	}
	return nil
}

func run() error {
	if err := sub1(); err != nil {
		return erero.WithMessage(err, "sub1 is wrong")
	}
	if err := sub2(); err != nil {
		return erero.WithMessagef(err, "sub2 is wrong")
	}
	return nil
}

func main() {
	if err := run(); err != nil {
		panic(erero.Wro(err))
	}
	fmt.Println("success")
}

License

erero is open-source and released under the MIT License. See the LICENSE file for more information.


Support

Welcome to contribute to this project by submitting pull requests or reporting issues.

If you find this package helpful, give it a star on GitHub!

Thank you for your support!

Happy Coding with erero! 🎉

Give me stars. Thank you!!!


Starring

starring

About

erero is a simple error-handling package designed to log errors along with their context and location.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published