Intégration de Sentry
This commit is contained in:
@ -1,10 +1,15 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"forge.cadoles.com/Cadoles/daddy/internal/config"
|
||||
"forge.cadoles.com/Cadoles/daddy/internal/graph"
|
||||
"forge.cadoles.com/Cadoles/daddy/internal/graph/generated"
|
||||
@ -44,6 +49,19 @@ func Mount(r *chi.Mux, config *config.Config) error {
|
||||
generated.NewExecutableSchema(gqlConfig),
|
||||
)
|
||||
|
||||
gql.SetRecoverFunc(func(ctx context.Context, err interface{}) error {
|
||||
// Dispatch error to Sentry
|
||||
if realErr, ok := err.(error); ok {
|
||||
sentry.CaptureException(realErr)
|
||||
}
|
||||
|
||||
if strErr, ok := err.(string); ok {
|
||||
sentry.CaptureException(errors.New(strErr))
|
||||
}
|
||||
|
||||
return graphql.DefaultRecover(ctx, err)
|
||||
})
|
||||
|
||||
gql.AddTransport(transport.POST{})
|
||||
gql.AddTransport(&transport.Websocket{
|
||||
KeepAlivePingInterval: 10 * time.Second,
|
||||
|
Reference in New Issue
Block a user