Skip to content

skit-ai/errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Errors

A wrapper over pkg/errors to enrich and enhance error handling. This package was moved out of vcore/errors for independent use and development.

Usage

To use this package, you need to have pkg/errors and this package in your system. For most cases this should mean doing

go get github.com/pkg/errors
go get github.com/skit-ai/errors

Then import this package as import "github.com/skit-ai/errors".

Migration from vcore/errors

The major difference between this major release and the version in vcore/errors is that functions have been demarcated with the functionality they provide and the context they are used in. So to create a basic new error now, all you need to do is call the NewError function with a message string. For example:

err := NewError("Error happened")

Almost all of the functions support formatted strings so you can also do something like:

num := 5
err := NewError("Errors occured %d times", num)

To chain a new error with an existing one, you need to use functions starting with the name Chain-. For example:

err := NewError("Error happened")
err = ChainError(err, "This happened due to another error")

Reference

All functions starting with New- in their name returns a fresh new error and those with Chain- in their name returns an error chained with the input error.

Check out the docs to know more.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages