Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions runtime/sentryutils/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,16 @@ func Recover(ctx context.Context, r any) {

func CaptureError(ctx context.Context, err error, msg string, opts ...func(event *sentry.Event)) {
hub := ActiveHub(ctx)
client := hub.Client()
Comment on lines 211 to +212
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the client retrieval and nil-check into a helper function to avoid duplicating this pattern in both CaptureError and CaptureWarning.

Suggested change
hub := ActiveHub(ctx)
client := hub.Client()
client := getClient(ctx)

Copilot uses AI. Check for mistakes.
if client == nil {
return
}

var event *sentry.Event
if err == nil {
event = hub.Client().EventFromMessage(msg, sentry.LevelError)
event = client.EventFromMessage(msg, sentry.LevelError)
} else {
event = hub.Client().EventFromException(err, sentry.LevelError)
event = client.EventFromException(err, sentry.LevelError)
event.Message = msg
}
for _, opt := range opts {
Expand All @@ -224,11 +229,16 @@ func CaptureError(ctx context.Context, err error, msg string, opts ...func(event

func CaptureWarning(ctx context.Context, err error, msg string, opts ...func(event *sentry.Event)) {
hub := ActiveHub(ctx)
client := hub.Client()
if client == nil {
return
}

var event *sentry.Event
if err == nil {
event = hub.Client().EventFromMessage(msg, sentry.LevelWarning)
event = client.EventFromMessage(msg, sentry.LevelWarning)
} else {
event = hub.Client().EventFromException(err, sentry.LevelWarning)
event = client.EventFromException(err, sentry.LevelWarning)
event.Message = msg
}
for _, opt := range opts {
Expand Down
Loading