Skip to content

Commit 74fdc67

Browse files
chore: improve error message incase of non-200 response (#177)
* chore: log the error message of the query in case of any non 200 response Signed-off-by: Siddhant N Trivedi <siddhant@deepsource.io> * Revert "chore: truncate hostname if greater than 256" This reverts commit 98e92f7.
1 parent acd96b2 commit 74fdc67

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

command/auth/login/login_flow.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ func fetchPAT(ctx context.Context, deviceRegistrationData *auth.Device) (*auth.P
101101
if err != nil {
102102
hostName = defaultHostName
103103
}
104-
if len(hostName) > 256 {
105-
hostName = hostName[:256]
106-
}
107-
userDescription := fmt.Sprintf("CLI : %s@%s", userName, hostName)
104+
userDescription := fmt.Sprintf("CLI PAT for %s@%s", userName, hostName)
108105

109106
// Fetching DeepSource client in order to interact with SDK
110107
deepsource, err := deepsource.New(deepsource.ClientOpts{

command/report/query.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package report
22

33
import (
44
"bytes"
5-
"errors"
5+
"fmt"
66
"io/ioutil"
77
"net/http"
88
"strconv"
@@ -34,7 +34,12 @@ func makeQuery(url string, body []byte, bodyMimeType string) ([]byte, error) {
3434
}
3535

3636
if res.StatusCode >= http.StatusInternalServerError || res.StatusCode != 200 {
37-
return resBody, errors.New("Error making the query with HTTP status code: " + strconv.Itoa(res.StatusCode))
37+
// Log the response body.
38+
if resBody != nil {
39+
fmt.Println(string(resBody))
40+
}
41+
42+
return resBody, fmt.Errorf("Error making the query with HTTP status code: %s and message: %s", strconv.Itoa(res.StatusCode), string(resBody))
3843
}
3944

4045
return resBody, nil

0 commit comments

Comments
 (0)