Skip to content

Commit d5d5223

Browse files
committed
Update changelog. Fix comments
1 parent 611ac9d commit d5d5223

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

CHANGES.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# v0.0.1 (2019-01-28)
1+
# v0.1.0 (2020-01-28)
22
- Initial release.
33

4-
# v0.0.2 (2019-01-29)
4+
# v0.2.0 (2020-01-29)
55
- Added `OnError()`.
66
- Added `Panic()`.
77
- Added `IsKnownCause()`.
8+
- Added `Handle()`.
89
- Fixed detection of existing error-formatting directive failing in special cases.
910
- Got rid of code generation.
11+
- Added tests, eliminating some issues.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func iAmAGoroutine(everythingChannel chan interface{}) interface{} {
7171
func iAmAnotherGoroutine() {
7272
defer panik.WriteTrace(os.Stderr)
7373
defer panik.Handle(func(r error) {
74-
// never reached: plain panic() is not an error which is or wraps a *panik.KnownCause.
74+
// never reached: plain panic() is not an error which is or wraps a *panik.knownCause.
7575
// Only panik.Panic() and panik.OnError() panic with such a value.
7676
})
7777
panic("very critical problem. DO NOT RECOVER")

panik.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
"sync"
1010
)
1111

12-
// Cause is an empty struct which signals that its position in a variadic argument list matches with a "%w" error-formatting directive.
12+
// Cause is an empty struct which signals that its position in a variadic argument list matches with a "%w" error-formatting directive
13+
// and that an error-value should take its place.
1314
type Cause struct{}
1415

1516
var describedErrors *sync.Map = &sync.Map{}
@@ -81,19 +82,19 @@ func OnError(err error, format string, args ...interface{}) {
8182
}
8283
}
8384

84-
// Panic panics with a value of type *panik.KnownCause which wraps an error with the provided formatted message.
85+
// Panic panics with a value of type *panik.knownCause which wraps an error with the provided formatted message.
8586
func Panic(format string, args ...interface{}) {
8687
panic(&knownCause{cause: fmt.Errorf(format, args...)})
8788
}
8889

89-
// IsKnownCause returns true when err or one of its wrapped errors is of type *panik.KnownCause, i.e. err came from a panic
90+
// IsKnownCause returns true when err or one of its wrapped errors is of type *panik.knownCause, i.e. err came from a panic
9091
// triggered using panik, or from To(Custom)Error (and not from somewhere else).
9192
func IsKnownCause(err error) bool {
9293
var known *knownCause
9394
return errors.As(err, &known)
9495
}
9596

96-
// Handle handles a panic if and only if the recovered value is an error err which is or wraps an error of type *panik.KnownCause,
97+
// Handle handles a panic if and only if the recovered value is an error err which is or wraps an error of type *panik.knownCause,
9798
// calling your provided function with the panic value type-asserted to an error value.
9899
func Handle(handler func(r error)) {
99100
r := recover()

0 commit comments

Comments
 (0)