-
Notifications
You must be signed in to change notification settings - Fork 697
Stacktrace don't print all stack #227
Comments
What version of Using Finally, you do not have to extract the stacktrace yourself to print it out. It should be printed out just by using |
@puellanivis i'm using "github.com/pkg/errors v0.9.1" version. i will try to refactor my code to using like you said, i will change today and i go back to say if work. @puellanivis thx for your help. |
@puellanivis i change the code... but not work exactly i want, i need to extract the stacktrace to report to the team, to be honest, i just use the pkg error to show the stacktrace, but the stracktrace just print the first 2 levels of my services, if i change wraps to WithMessage, the stacktrace dont show. i tried to use WithStack(err) to chain and just when the cause started i use Wrap, but the stacktrace dont show the entire stacktrace. |
Using code:
Print:
Using the second code:
print: myrepos/conductortech/prepaid/_git/orchestrator.git/internal/delivery/cards.(*RestImpl).CardDetails C:/Workspace/prepaid/orchestrator/internal/delivery/cards/rest.go:45 myrepos/conductortech/prepaid/_git/orchestrator.git/internal/service.CardServiceImpl.GetCard C:/Workspace/prepaid/orchestrator/internal/service/card.go:28 myrepos/conductortech/prepaid/_git/orchestrator.git/internal/service.AuthorizationServiceImpl.GetDetails C:/Workspace/prepaid/orchestrator/internal/service/authorization.go:39 myrepos/conductortech/prepaid/_git/orchestrator.git/cmd/http/handlers.AuthorizationController.checkAuthorization C:/Workspace/prepaid/orchestrator/cmd/http/handlers/authorizations.go:48 net/http.HandlerFunc.ServeHTTP C:/Go/src/net/http/server.go:2007 github.com/go-chi/chi.(*Mux).routeHTTP C:/Users/marcos.filho/go/pkg/mod/github.com/go-chi/chi@v4.0.3+incompatible/mux.go:425 net/http.HandlerFunc.ServeHTTP The problem it's happen only if i limit the stack, the correct stack is the second code, But is too Huge, i want to limit the print. But if i limit the code don't print first two lines (in bold), this lines are most important for the stacktrace. it's a bug ? |
Yes,
The You need to only attach the stack trace at the very first level. if you do not actually care about the messages, then just use If you still actually do want the messages, then at Do:
If you’re not using |
thx u so much @puellanivis it worked very well. As you said, i was doing wrong, now at the first level i'm using WithStack and after that i'm just return the error, not wrap anymore. And now when i limit the message work very well. |
Current scenario.
AuthorizationService has a GetDetails function that call a CardService GetCard function.
CardService has a GetCard function that call a CardDelivery CardDetails function
CardDelivery has a CardDetails function that call a HttpClient Post
my problem occuring this last function but when i print the stacktrace they are not show the last 2 functions:
the last two services are not printed in the stacktrace, but they are wrapped with errors.Wrap(err, msg)
My code to print the stacktrace:
i'm doing anything wrong ?
The text was updated successfully, but these errors were encountered: