As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 4b6d45aa authored by Joseph Snyder's avatar Joseph Snyder
Browse files

Add StatusCode check for client call

Ensure that the value of the response is in the acceptable range.
parent 78ca52ba
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,6 +3,7 @@ package lfstransfer
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
Loading
Loading
@@ -90,6 +91,11 @@ func (c *Client) Batch(operation string, reqObjects []*BatchObject, ref string,
return nil, err
}
// Error condition taken from example: https://pkg.go.dev/net/http#example-Get
if res.StatusCode > 399 {
return nil, errors.New(fmt.Sprintf("Response failed with status code: %d", res.StatusCode))
}
defer func() { _ = res.Body.Close() }()
response := &BatchResponse{}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment