Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Oct 15, 2024
1 parent a1ce33d commit 394b8c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/client/peer/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c Client) GetSubleaseToken(ctx context.Context, accountName models.Account
return "", err
}
if respStatusCode != http.StatusOK {
return "", fmt.Errorf("during POST %s: expected 200, got %d with response: %s",
return "", fmt.Errorf("while obtaining sublease token with POST %s: expected 200, got %d with response: %s",
reqURL, respStatusCode, string(respBodyBytes))
}

Expand All @@ -101,7 +101,7 @@ func (c Client) GetSubleaseToken(ctx context.Context, accountName models.Account
}{}
err = jsonUnmarshalStrict(respBodyBytes, &data)
if err != nil {
return "", fmt.Errorf("while parsing response for POST %s: %w", reqURL, err)
return "", fmt.Errorf("while parsing sublease token response from POST %s: %w", reqURL, err)
}
return data.SubleaseToken, nil
}
Expand All @@ -116,7 +116,7 @@ func (c Client) PerformReplicaSync(ctx context.Context, fullRepoName string, pay
reqURL := c.buildRequestURL("peer/v1/sync-replica/" + fullRepoName)
reqBodyBytes, err := json.Marshal(payload)
if err != nil {
return nil, fmt.Errorf("during POST %s: %w", reqURL, err)
return nil, fmt.Errorf("while marshalling POST %s: %w", reqURL, err)
}

respBodyBytes, respStatusCode, _, err := c.doRequest(ctx, http.MethodPost, reqURL, bytes.NewReader(reqBodyBytes), nil)
Expand All @@ -136,7 +136,7 @@ func (c Client) PerformReplicaSync(ctx context.Context, fullRepoName string, pay
var respPayload keppel.ReplicaSyncPayload
err = jsonUnmarshalStrict(respBodyBytes, &respPayload)
if err != nil {
return nil, fmt.Errorf("while parsing response for POST %s: %w", reqURL, err)
return nil, fmt.Errorf("while parsing response from POST %s: %w", reqURL, err)
}
return &respPayload, nil
}
Expand Down

0 comments on commit 394b8c8

Please sign in to comment.