Categorygithub.com/go-zoox/errors
modulepackage
1.0.2
Repository: https://github.com/go-zoox/errors.git
Documentation: pkg.go.dev

# README

errors - Simple Errors Wrapper

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/errors

Getting Started

package main

import (
    stderrors "errors"

    "github.com/go-zoox/errors"
)

func main() {
    err := f3()
    
    fmt.Println(err)
}

func f1() error {
    return errors.New("string1")
}

func f2() error {
    return errors.Wrap(f1(), "custom message f2")
}

func f3() error {
    return errors.Wrapf(f2(), "custom message f3 %s", "test")
}

Inspired by

  • PumpkinSeed/errors - Simple and efficient error package.
  • bnkamalesh/errors - A drop-in replacement for Go errors, with some added sugar! Unwrap user-friendly messages, HTTP status code, easy wrapping with multiple error types.
  • pkg/errors - imple error handling primitives.

License

GoZoox is released under the MIT License.

# Functions

Errorf formats according to a format specifier and returns the string as a value that satisfies error.
New returns an error that formats as the given text.
Wrap returns an error annotating err with message.
Wrapf returns an error annotating err with the format specifier.