Skip to content

Commit

Permalink
Revert conditional chaining (#966)
Browse files Browse the repository at this point in the history
* Revert conditional chaining

* Apply suggestions from code review

Co-authored-by: DavidGOrtega <[email protected]>

* lint fix

Co-authored-by: DavidGOrtega <[email protected]>
  • Loading branch information
0x2b3bfa0 and DavidGOrtega authored Apr 14, 2022
1 parent e51531f commit 3a45186
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/drivers/bitbucket_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,12 @@ class BitbucketCloud {
// Attempt to get additional context. We have observed two different error schemas
// from BitBucket API responses: `{"error": {"message": "Error message"}}` and
// `{"error": "Error message"}`, apart from plain text responses like `Bad Request`.
const error =
responseBody?.error?.message || responseBody?.error || responseBody;
throw new Error(`${response.statusText} ${error}`.trim());
const { error } = responseBody.error
? responseBody
: { error: responseBody };
throw new Error(
`${response.statusText} ${error.message || error}`.trim()
);
}

return responseBody;
Expand Down

1 comment on commit 3a45186

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.