Created
October 13, 2022 16:07
-
-
Save andreafalzetti/dda479e89c4795d2922f89a6a91b4757 to your computer and use it in GitHub Desktop.
How to get the stacktrace of an errror in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
go_errors "github.com/go-errors/errors" | |
) | |
func main() { | |
err := errors.New("something happened..") | |
if err != nil { | |
newErr := go_errors.New(err) | |
fmt.Println(newErr.ErrorStack()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another approach, inspired by Sentry's GO SDK: