@@ -103,7 +103,8 @@ tolerant*. And, of course, it helps to make your code error-safe.
103
103
handler.
104
104
3 . It helps us use design-by-contract type preconditions.
105
105
4 . It offers automatic stack tracing for every error, runtime error, or panic.
106
- If you are familiar with Zig, the ` err2 ` error traces are same as Zig's.
106
+ If you are familiar with Zig, the ` err2 ` error return traces are same as
107
+ Zig's.
107
108
108
109
You can use all of them or just the other. However, if you use ` try ` for error
109
110
checks, you must remember to use Go's ` recover() ` by yourself, or your error
@@ -152,7 +153,11 @@ own purposes.
152
153
153
154
#### Error Stack Tracing
154
155
155
- The err2 offers optional stack tracing. It's *automatic* and *optimized*.
156
+ The err2 offers optional stack tracing in two different formats:
157
+ 1. Optimized call stacks (` -err2-trace` )
158
+ 1. Error return traces similar to Zig (` -err2-ret-trace` )
159
+
160
+ Both are *automatic* and fully *optimized*.
156
161
157
162
<details>
158
163
<summary>The example of the optimized call stack:</summary>
@@ -177,12 +182,14 @@ main.main()
177
182
178
183
</details>
179
184
180
- Just set the ` err2.SetErrorTracer ` or ` err2.SetPanicTracer ` to the stream you
181
- want traces to be written:
185
+ Just set the ` err2.SetErrorTracer ` , ` err2.SetErrRetTracer ` or
186
+ ` err2. SetPanicTracer ` to the stream you want traces to be written:
182
187
183
188
` ` ` go
184
189
err2.SetErrorTracer (os.Stderr ) // write error stack trace to stderr
185
190
// or, for example:
191
+ err2.SetErrRetTracer (os.Stderr ) // write error return trace (like Zig)
192
+ // or, for example:
186
193
err2.SetPanicTracer (log.Writer ()) // stack panic trace to std logger
187
194
` ` `
188
195
@@ -382,12 +389,12 @@ func TestWebOfTrustInfo(t *testing.T) {
382
389
// And if there's violations during the test run they are reported as
383
390
// test failures for this TestWebOfTrustInfo -test.
384
391
385
- assert.Equal (0 , wot.CommonInvider )
386
- assert.Equal (1 , wot.Hops )
392
+ assert.Equal (wot.CommonInvider , 0 )
393
+ assert.Equal (wot.Hops , 1 )
387
394
388
395
wot = NewWebOfTrust (bob.Node , carol.Node )
389
- assert.Equal (- 1 , wot.CommonInvider )
390
- assert.Equal (- 1 , wot.Hops )
396
+ assert.Equal (wot.CommonInvider , hop. NotConnected )
397
+ assert.Equal (wot.Hops , hop. NotConnected )
391
398
...
392
399
` ` `
393
400
@@ -592,6 +599,15 @@ been much easier.** There is an excellent [blog post](https://jesseduffield.com/
592
599
about the issues you are facing with Go's error handling without the help of
593
600
the err2 package.
594
601
602
+ - If you don't want to bubble up error from every function, we have learned that
603
+ ` Try` prefix convention is pretty cool way to solve limitations of Go
604
+ programming language help to make your code more skimmable. If your internal
605
+ functions normally would be something like ` func CopyFile (s, t string ) (err
606
+ error )` , you can replace them with ` func TryCopyFile (s, t string )` , where ` Try`
607
+ prefix remind you that the function throws errors. You can decide at what level
608
+ of the call stack you will catch them with ` err2.Handle ` or ` err2.Catch ` ,
609
+ depending your case and API.
610
+
595
611
</details>
596
612
597
613
## Support And Contributions
@@ -607,14 +623,10 @@ Please see the full version history from [CHANGELOG](./CHANGELOG.md).
607
623
608
624
### Latest Release
609
625
610
- ##### 1.1.0
611
- - ` assert` package:
612
- - bug fix: call stack traversal during unit testing in some situations
613
- - **all generics-based functions are inline expansed**
614
- - *performance* is now *same as if-statements for all functions*
615
- - new assert functions: ` MNil` , ` CNil` , ` Less` , ` Greater` , etc.
616
- - all assert messages follow Go idiom: ` got, want`
617
- - ` Asserter` can be set per goroutine: ` PushAsserter`
618
- - ` try` package:
619
- - new check functions: ` T` , ` T1` , ` T2` , ` T3` , for quick refactoring from ` To` functions to annotate an error locally
620
- - **all functions are inline expansed**: if-statement equal performance
626
+ ##### 1.2.0
627
+ - Now ` -err2-ret-trace` and ` err2.SetErrRetTracer ` gives us *error return traces*
628
+ which are even more readable than ` -err2-trace` , ` err2.SetErrorTracer ` with
629
+ long error return traces
630
+ - A new automatic error formatter/generator added for ` TryCopyFile` convention
631
+ - New features for ` sample/` to demonstrate latest features
632
+ - Extended documentation
0 commit comments