From 2f5b771fd24539682140d17b70b0611791f1177e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norbert=20Radvilovi=C4=8D?= Date: Tue, 27 Feb 2024 13:41:41 +0200 Subject: [PATCH] Fix: handle bad requests during job creation --- internal/async_helpers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/async_helpers.go b/internal/async_helpers.go index faf0ec5..1f72075 100644 --- a/internal/async_helpers.go +++ b/internal/async_helpers.go @@ -33,7 +33,11 @@ func (c *Client) GetJobID( if err != nil { return "", fmt.Errorf("error reading resp body: %v", err) } - resp.Body.Close() + defer resp.Body.Close() + + if resp.StatusCode >= 300 { + return "", fmt.Errorf("error creating job: %s", respBody) + } // Unmarshal into job. job := &Job{}