Let's say I have a code like this:
value, err := some3rdpartylib.DoSomething() if err != nil { panic(err) }
In the case of err != nil I get something like this:
panic: some error explanation here goroutine 1 [running]: main.main() /tmp/blabla/main.go:6 +0x80
This stack trace is legitimate, but sometimes these error messages may not clarify what happened, and therefore I would like to delve into the source code of a third-party library to find out what exactly causes this error to be returned. However, when my panic code is like this, there is no way to get the actual location that returned this error.
A bit more clarification: since I come from the JVM world where exceptions are thrown, I can completely trace which line of code the exception was thrown and, therefore, can easily find the place and see what went wrong. The stack trace ends exactly where my code panics and therefore is not very useful in my case.
I created a playground here , and ideally I would like to trace the error to the place where it was actually returned from, not the panic. (e.g. line 17, return "", errors.New("some error explanation here") )
Is it possible?
source share