Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nofeaturesonlybugs/errors
golang extended error package.
https://github.com/nofeaturesonlybugs/errors
error-handling error-reporting errors go golang stack stacktrace
Last synced: 8 days ago
JSON representation
golang extended error package.
- Host: GitHub
- URL: https://github.com/nofeaturesonlybugs/errors
- Owner: nofeaturesonlybugs
- License: mit
- Created: 2020-09-02T22:37:38.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-12T16:04:21.000Z (over 2 years ago)
- Last Synced: 2023-07-27T22:24:50.543Z (over 1 year ago)
- Topics: error-handling, error-reporting, errors, go, golang, stack, stacktrace
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.txt
- License: LICENSE
Awesome Lists containing this project
README
[![Go Reference](https://pkg.go.dev/badge/github.com/nofeaturesonlybugs/errors.svg)](https://pkg.go.dev/github.com/nofeaturesonlybugs/errors)
[![Go Report Card](https://goreportcard.com/badge/github.com/nofeaturesonlybugs/errors)](https://goreportcard.com/report/github.com/nofeaturesonlybugs/errors)
[![Build Status](https://app.travis-ci.com/nofeaturesonlybugs/errors.svg?branch=master)](https://app.travis-ci.com/nofeaturesonlybugs/errors)
[![codecov](https://codecov.io/gh/nofeaturesonlybugs/errors/branch/master/graph/badge.svg)](https://codecov.io/gh/nofeaturesonlybugs/errors)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)golang package for enhanced errors that capture file and line number information, the call stack, relevant identifiers, and a handle back to the original error for type switching.
Replacement for fmt.Errorf(...):
```go
err := errors.Errorf("Failed to do something; here's a value %v",len(data))
fmt.Printf("%#v\n",err) // Prints full stack trace.
```Wrap another function's error:
```go
_, err := net.Dial( "tcp", "localhost:8080" )
if err != nil {
return errors.Go( err )
}
```Obtain the original error in order to type switch:
```go
func connect() error {
_, err := net.Dial( "tcp", "localhost:0" )
if err != nil {
return errors.Go( err )
}
return nil
}err := connect()
switch errors.Original( err ).(type) {
case *net.OpError:
// We know the original type!
}
```See the godoc link for more information.