You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am integrating Sentry into a Go application that uses Fiber and Fx for dependency injection. The issue I am facing is that the stack traces captured by Sentry consistently highlight the line where hub.CaptureException(err) is called, rather than the original source of the error. This makes it challenging to identify where the error originated.
Let's say I have some function that is going to return some error
func() *fiber.App {
app:=fiber.New(fiber.Config{
ErrorHandler: utils.NewErrorHandler(),
JSONEncoder: json.Marshal,
JSONDecoder: json.Unmarshal,
})
// Sentry MiddlewaresentryHandler:=sentryfiber.New(sentryfiber.Options{
Repanic: true,
WaitForDelivery: true,
})
app.Use(sentryHandler)
returnapp
}
// utils/error.go// NewErrorHandler returns a custom error handler for FiberfuncNewErrorHandler() fiber.ErrorHandler {
returnfunc(c*fiber.Ctx, errerror) error {
// Determine status code and message based on the errorstatusCode, message:=getErrorDetails(err)
// Capture error in Sentryifhub:=sentryfiber.GetHubFromContext(c); hub!=nil {
hub.WithScope(func(scope*sentry.Scope) {
scope.SetTag("status_code", fmt.Sprintf("%d", statusCode))
scope.SetTag("endpoint", c.Path())
// If the error is of type *fiber.Error, add the status code and messageiffiberErr, ok:=err.(*fiber.Error); ok {
scope.SetTag("fiber_error_code", fmt.Sprintf("%d", fiberErr.Code))
scope.SetExtra("fiber_error_message", fiberErr.Message)
}
// Capture the exceptionhub.CaptureException(err)
})
}
// Return a JSON response with the status code and messagereturnc.Status(statusCode).JSON(GlobalErrorHandlerResp{
Success: false,
Message: message,
})
}
}
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
Question Description
I am integrating Sentry into a Go application that uses Fiber and Fx for dependency injection. The issue I am facing is that the stack traces captured by Sentry consistently highlight the line where hub.CaptureException(err) is called, rather than the original source of the error. This makes it challenging to identify where the error originated.
Let's say I have some function that is going to return some error
Code Snippet (optional)
Checklist:
The text was updated successfully, but these errors were encountered: