From e49334c15968827af67ea3aa9aeffc0495addbfb 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..d367182 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 with status code %s: %s", resp.Status, respBody) + } // Unmarshal into job. job := &Job{}