This PR makes sure that the HTTP errors (GenericSwaggerError) is actually handled whenever it is returned.
We differentiate between normal error objects and GenericSwaggerError by testing a type cast. I tried to wrap this logic in a helper function we can easily use throughout any of the resources.
Example error output:
REST Error
bitbucket_branch_restriction.development: Creating...
╷
│ Error: 409 Conflict: a branch restriction with that kind (force) and branch type (development) already exists (id=34493232)
│
│ with bitbucket_branch_restriction.development,
│ on example.tf line 13, in resource "bitbucket_branch_restriction" "development":
│ 13: resource "bitbucket_branch_restriction" "development" {
│
╵
Auth Error
bitbucket_branch_restriction.development: Creating...
╷
│ Error: Login failed due to incorrect login credentials or method.
│ For information on authentication methods for Bitbucket Cloud APIs, visit:
│ https://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication
│ If you are unsure of which login details or login method to use, visit:
│ https://support.atlassian.com/bitbucket-cloud/docs/log-into-or-connect-to-bitbucket-cloud/
│
│
│ with bitbucket_branch_restriction.development,
│ on example.tf line 13, in resource "bitbucket_branch_restriction" "development":
│ 13: resource "bitbucket_branch_restriction" "development" {
│
This PR makes sure that the HTTP errors (
GenericSwaggerError
) is actually handled whenever it is returned.We differentiate between normal
error
objects andGenericSwaggerError
by testing a type cast. I tried to wrap this logic in a helper function we can easily use throughout any of the resources.Example error output:
REST Error
Auth Error
Relates to #93