fix(webhook/client): error on http status codes >= 400

This commit is contained in:
Dorian de Koning
2022-11-25 09:49:25 +01:00
committed by Julien Neuhart
parent 1f784ad44c
commit 1de0f4c4fa
2 changed files with 34 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package webhook
import (
"fmt"
"io"
"net/http"
"strconv"
"time"
@@ -78,6 +79,10 @@ func (c client) send(body io.Reader, headers map[string]string, erroed bool) err
return fmt.Errorf("send '%s' request to '%s': %w", method, URL, err)
}
if resp.StatusCode >= http.StatusBadRequest {
return fmt.Errorf("send '%s' request to '%s': got status: '%s'", method, URL, resp.Status)
}
defer func() {
err := resp.Body.Close()
if err != nil {