Skip to content

Commit 3f46da0

Browse files
simplify errorstack
1 parent 5dd12d0 commit 3f46da0

20 files changed

+365
-1938
lines changed

.gitignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

LICENSE

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
1-
Copyright (c) 2015, Dave Cheney <[email protected]>
2-
All rights reserved.
1+
Copyright 2023, Ahmad Elsagheer <[email protected]>
32

4-
Redistribution and use in source and binary forms, with or without
5-
modification, are permitted provided that the following conditions are met:
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
64

7-
* Redistributions of source code must retain the above copyright notice, this
8-
list of conditions and the following disclaimer.
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
96

10-
* Redistributions in binary form must reproduce the above copyright notice,
11-
this list of conditions and the following disclaimer in the documentation
12-
and/or other materials provided with the distribution.
13-
14-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 0 additions & 44 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,7 @@
1-
# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge)
1+
# errorstack
22

3-
Package errors provides simple error handling primitives.
3+
A lightweight package to get stacktrace of go errors. Designed to work with go1.21+
44

5-
`go get github.com/pkg/errors`
5+
This is a fork of [pkg/errors](https://github.com/pkg/errors) which is archived now. The package has been simplified to provide only stacktrace functionality.
66

7-
The traditional error handling idiom in Go is roughly akin to
8-
```go
9-
if err != nil {
10-
return err
11-
}
12-
```
13-
which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error.
14-
15-
## Adding context to an error
16-
17-
The errors.Wrap function returns a new error that adds context to the original error. For example
18-
```go
19-
_, err := ioutil.ReadAll(r)
20-
if err != nil {
21-
return errors.Wrap(err, "read failed")
22-
}
23-
```
24-
## Retrieving the cause of an error
25-
26-
Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`.
27-
```go
28-
type causer interface {
29-
Cause() error
30-
}
31-
```
32-
`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example:
33-
```go
34-
switch err := errors.Cause(err).(type) {
35-
case *MyError:
36-
// handle specifically
37-
default:
38-
// unknown error
39-
}
40-
```
41-
42-
[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors).
43-
44-
## Roadmap
45-
46-
With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows:
47-
48-
- 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible)
49-
- 1.0. Final release.
50-
51-
## Contributing
52-
53-
Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports.
54-
55-
Before sending a PR, please discuss your change by raising an issue.
56-
57-
## License
58-
59-
BSD-2-Clause
7+
## Usage

appveyor.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

bench_test.go

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)