From dc68fa3bcd2f0f5c4ae39eeaca63165152714257 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Fri, 7 Mar 2025 15:37:07 -0600 Subject: [PATCH] Add a bot check to avoid annoying error emails. --- client.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index ed5e7e2..3bc6a68 100644 --- a/client.go +++ b/client.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "strings" "time" "git.sr.ht/~emersion/gqlclient" @@ -80,9 +81,19 @@ func Execute(ctx context.Context, op *gqlclient.Operation, result interface{}) e client = gqlclient.New(origin, httpClient) err := client.Execute(ctx, op, &result) - if graphErrors, ok := err.(interface{ Unwrap() []error }); ok { - errs := graphErrors.Unwrap() - err = errs[0] + if err != nil { + if graphErrors, ok := err.(interface{ Unwrap() []error }); ok { + errs := graphErrors.Unwrap() + err = errs[0] + } else { + estr := err.Error() + if strings.HasPrefix(estr, "HTTP request failed:") && + strings.HasSuffix(estr, "context canceled") { + // Stupid f'n bots. Return this because gobwebs will not send an error email + // for this error + return context.Canceled + } + } } return err } -- 2.45.3