https://github.com/ashwin-rajeev/goerror
A complete error handler for Golang
https://github.com/ashwin-rajeev/goerror
error error-handling golang golang-library golang-package golang-tools
Last synced: 8 months ago
JSON representation
A complete error handler for Golang
- Host: GitHub
- URL: https://github.com/ashwin-rajeev/goerror
- Owner: Ashwin-Rajeev
- License: bsd-2-clause
- Created: 2018-11-16T10:58:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-19T07:09:47.000Z (about 7 years ago)
- Last Synced: 2024-06-21T08:58:36.131Z (over 1 year ago)
- Topics: error, error-handling, golang, golang-library, golang-package, golang-tools
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goerror [](https://travis-ci.com/Ashwin-Rajeev/goerror) [](https://goreportcard.com/report/github.com/Ashwin-Rajeev/goerror) [](https://godoc.org/github.com/Ashwin-Rajeev/goerror)
Package goerror implements functions to manipulate errors.
The traditional `error` handling method in golang is given below
which applied recursively up the call stack results in error reports without context or debugging information.
```
if err != nil {
return err
}
```
The package mainly contain three **functions**
> GetErrorInfo
> GetErrorType
> New
## GetErrorInfo
which accepts the error and found the detailed information about the error.
`GetErrorInfo` returns the error wrapped up with the `file name`,
`line number` and `function name` in which error occured.
> func GetErrorInfo(err error) error
```
if err != nil {
return goerror.GetErrorInfo(err)
}
```
## GetErrorType
which accepts the error and found the type of the error.
`GetErrorType` returns the error wrapped up with the `error type`,
> func GetErrorType(err error) error
```
if err != nil {
return goerror.GetErrorType(err)
}
```
## New
Which is used to create a new errors.
New help us to create custom user defined errors.
> func New(err string) error
```
err := goerror.New("New custom error")
```
## Contributing
We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. Before proposing a change, please discuss your change by raising an issue.
## License
BSD-2-Clause