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
.
go get github.com/yyle88/erero
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")
}
MIT License. See LICENSE.
Contributions are welcome! To contribute:
- Fork the repo on GitHub (using the webpage interface).
- Clone the forked project (
git clone https://github.com/yourname/repo-name.git
). - Navigate to the cloned project (
cd repo-name
) - Create a feature branch (
git checkout -b feature/xxx
). - Stage changes (
git add .
) - Commit changes (
git commit -m "Add feature xxx"
). - Push to the branch (
git push origin feature/xxx
). - Open a pull request on GitHub (on the GitHub webpage).
Please ensure tests pass and include relevant documentation updates.
Welcome to contribute to this project by submitting pull requests and reporting issues.
If you find this package valuable, give me some stars on GitHub! Thank you!!!
Thank you for your support!
Happy Coding with this package! 🎉
Give me stars. Thank you!!!