From 373f0a7cdd1136f2433ff0d48f1b9e4f4f2414cd Mon Sep 17 00:00:00 2001 From: libmartinito Date: Fri, 14 Jun 2024 20:25:12 +0800 Subject: [PATCH] refactor: Move sentry capture exception outside loop --- internal/utils/codecrafters_client.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/utils/codecrafters_client.go b/internal/utils/codecrafters_client.go index 4c5957d..0005fd6 100644 --- a/internal/utils/codecrafters_client.go +++ b/internal/utils/codecrafters_client.go @@ -191,10 +191,7 @@ func (c CodecraftersClient) FetchBuild(buildId string) (FetchBuildStatusResponse } if fetchBuildResponse.Status != "failure" && fetchBuildResponse.Status != "success" { - err = fmt.Errorf("unexpected build status: %s", fetchBuildResponse.Status) - - sentry.CaptureException(err) - return err + return fmt.Errorf("unexpected build status: %s", fetchBuildResponse.Status) } return nil @@ -207,6 +204,10 @@ func (c CodecraftersClient) FetchBuild(buildId string) (FetchBuildStatusResponse ) if err != nil { + if fetchBuildResponse.Status != "failure" && fetchBuildResponse.Status != "success" { + sentry.CaptureException(err) + } + return FetchBuildStatusResponse{}, err }