Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mizutani committed Apr 6, 2024
1 parent f944fe9 commit afb8512
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/stacktrace_extract/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ func someAction(fname string) error {

func main() {
if err := someAction("no_such_file.txt"); err != nil {
// NOTE: `errors.Unwrap` also works
/*
// NOTE: errors.As also works
var goErr *goerr.Error
if errors.As(err, &goErr); goErr != nil {
*/
if goErr := goerr.Unwrap(err); goErr != nil {
for i, st := range goErr.Stacks() {
log.Printf("%d: %v\n", i, st)
log.Printf("%d: %+v\n", i, st)
}
}
log.Fatal(err)
Expand Down

0 comments on commit afb8512

Please sign in to comment.