errors

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: MIT Imports: 5 Imported by: 14

README

errors

Build Status Go Report Card Coverage Status GoDoc

extension of errors for the following features:

  • annotation error
  • error with code, support grpc error code
  • error by value
  • error with stack

Quick Start


import "github.com/x-mod/errors"

//annotation error
e1 := errors.Annotate(err, "annotations")
e11 := errors.Annotatef(err, "annotations %s", "format")

//code error
e2 := errors.WithCode(err, YourCode)
//get error's code value
v2 := errors.ValueFrom(e2)

e3 := errors.WithStack(err)
//print stack info
fmt.Printf("%v", e3)

//pure value error
e4 := errors.ValueErr(5)
v4 := errors.ValueFrom(e4)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Annotate

func Annotate(err error, annotation string) error

Annotate an error with annotation

func Annotatef

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

Annotatef an error with annotation

func CauseFrom

func CauseFrom(err error) error

CauseFrom get original error

func CodeError

func CodeError(code Code) error

CodeError a new error from code

func Errorf

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

Errorf standard func

func New

func New(err string) error

New errorstring error

func ValueErr added in v0.1.5

func ValueErr(v int32) error

ValueErr pure value error

func ValueFrom

func ValueFrom(err error) int32

ValueFrom get code from the error support code value from grpc status

func WithCode

func WithCode(err error, code Code) error

WithCode wrap err with code

func WithStack

func WithStack(err error) error

WithStack error

Types

type Code

type Code interface {
	Value() int32
	String() string
}

Code interface

Jump to

Keyboard shortcuts

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