Skip to content

Commit

Permalink
Use correct formatter based on data type
Browse files Browse the repository at this point in the history
Signed-off-by: Md Soharab Ansari <[email protected]>
  • Loading branch information
soharab-ic committed Sep 9, 2024
1 parent 8e90b68 commit 567713a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,25 @@ func HandleHTTPRequest(message string, headers http.Header, data ConnectorMetada
}

if resp == nil {
errResp.Response.ErrorString = fmt.Sprintf("every function invocation retry failed; final retry gave empty response. http_endpoint: %v, source: %v", data.HTTPEndpoint, data.SourceName)
errResp.Response.ErrorString = fmt.Sprintf("every function invocation retry failed; final retry gave empty response. http_endpoint: %s, source: %s", data.HTTPEndpoint, data.SourceName)
errorBytes, err := json.Marshal(errResp)
if err != nil {
return nil, fmt.Errorf("failed marshalling error response. http_endpoint: %v, source: %v", data.HTTPEndpoint, data.SourceName)
return nil, fmt.Errorf("failed marshalling error response. http_endpoint: %s, source: %s", data.HTTPEndpoint, data.SourceName)
}
return nil, errors.New(string(errorBytes))
}

if resp.StatusCode < 200 || resp.StatusCode > 300 {
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed reading response body. http_endpoint: %v, source: %v", data.HTTPEndpoint, data.SourceName)
return nil, fmt.Errorf("failed reading response body. http_endpoint: %s, source: %s", data.HTTPEndpoint, data.SourceName)
}
errResp.Response.ResponseBody = string(body)
errResp.Response.StatusCode = resp.StatusCode
errResp.Response.ErrorString = fmt.Sprintf("request returned failure: %v. http_endpoint: %v, source: %v", resp.StatusCode, data.HTTPEndpoint, data.SourceName)
errResp.Response.ErrorString = fmt.Sprintf("request returned failure: %d. http_endpoint: %s, source: %s", resp.StatusCode, data.HTTPEndpoint, data.SourceName)
errorBytes, err := json.Marshal(errResp)
if err != nil {
return nil, fmt.Errorf("failed marshalling error response. http_endpoint: %v, source: %v", data.HTTPEndpoint, data.SourceName)
return nil, fmt.Errorf("failed marshalling error response. http_endpoint: %s, source: %s", data.HTTPEndpoint, data.SourceName)
}
return nil, errors.New(string(errorBytes))
}
Expand Down

0 comments on commit 567713a

Please sign in to comment.