Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example: rpcServer := proto.NewVideoServer(app.Rpc) rpcServer.OnError = func(r *http.Request, err *proto.WebRPCError) { ctx := r.Context() // Log error with request log httplog.LogEntrySetField(ctx context.Context, "webrpcError", err.Error()) // Report crucial DB errors to Sentry var pgErr *pgconn.PgError if errors.As(err, &pgErr) { // https://www.postgresql.org/docs/16/errcodes-appendix.html if strings.HasPrefix(pgErr.Code, "42") { sentry.CaptureException(err) } } // Add requestID to error message itself. rpcErr.Message = fmt.Sprintf("%s (requestID: %v)", rpcErr.Message, middleware.GetReqID(ctx)) // Hide error details from users in production. if app.Config.Environment.IsProduction() { rpcErr.Cause = "" } }
- Loading branch information