Skip to content

Commit

Permalink
change bitbucket client errors
Browse files Browse the repository at this point in the history
Fix some typos in the existing error messages.
Distinguish between Bitbucket Cloud and Bitbucket Server for API errors.
  • Loading branch information
lgellrich committed Feb 17, 2022
1 parent be4c70d commit bf76180
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions service/bitbucket/cloud_api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ func (c *CloudAPIClient) CreateOrUpdateAnnotations(ctx context.Context, req *Ann
Execute()

if err := c.checkAPIError(err, resp, http.StatusOK); err != nil {
return fmt.Errorf("failed to create code insighsts annotations: %w", err)
return fmt.Errorf("failed to create code insights annotations: %w", err)
}

return nil
}

func (c *CloudAPIClient) checkAPIError(err error, resp *http.Response, expectedCode int) error {
if err != nil {
return fmt.Errorf("bitubucket API error: %w", err)
return fmt.Errorf("Bitbucket Cloud API error: %w", err)
}

if resp != nil && resp.StatusCode != expectedCode {
Expand Down
4 changes: 2 additions & 2 deletions service/bitbucket/server_api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ func (c *ServerAPIClient) deleteReport(ctx context.Context, report *ReportReques
Execute()

if err := c.checkAPIError(err, resp, http.StatusNoContent); err != nil {
return fmt.Errorf("failted to delete code insights report: %w", err)
return fmt.Errorf("failed to delete code insights report: %w", err)
}

return nil
}

func (c *ServerAPIClient) checkAPIError(err error, resp *http.Response, expectedCode int) error {
if err != nil {
return fmt.Errorf("bitubucket API error: %w", err)
return fmt.Errorf("Bitbucket Server API error: %w", err)
}

if resp != nil && resp.StatusCode != expectedCode {
Expand Down

0 comments on commit bf76180

Please sign in to comment.