erero

package module
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 2 Imported by: 27

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target any) bool

func Ase

func Ase(err error, target any) bool

func Ero

func Ero(err error) error

func Errorf

func Errorf(format string, args ...interface{}) error

func Is

func Is(err, target error) bool

func Ise

func Ise(err, target error) bool

func New

func New(message string) error

func WithMessage

func WithMessage(err error, message string) error

func WithMessagef

func WithMessagef(err error, format string, args ...interface{}) error

func Wrap added in v1.0.15

func Wrap(err error, message string) error

func Wrapf added in v1.0.15

func Wrapf(err error, format string, args ...interface{}) error

func Wro

func Wro(err error) error

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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