terraform-provider-ibm
terraform-provider-ibm copied to clipboard
feat: use new standardized structures for errors
This adds support for the new error formats designed for IBM Cloud services and tools. The support is only added in select VPC resources/ data sources for now. The support comes from wrapping the provider to catch errors and re-format them with the new system, so that the change to the actual resource/data source code has as small of a surface area as possible.
The primary change to resource code comes in the from of updating calls to fmt.Errorf
to be calls to a new wrapper function, flex.FmtErrorf
. It accepts the same arguments but instead of wrapping errors coming from the underlying Go SDK so that we retain only the message, it detects those errors and returns them so that we preserve all of the information needed for the new error formats.
With this change, error messages will now include more information about the problem and will include an identifying hash that allows the user to lookup more information about the specific error scenario that occurred.
cc @hkantare @astha-jain - this is part of the identifiable error work we have been discussing the last couple of months. It enables the new error formats for some of the VPC resources (the ones that use Create
instead of CreateContext
, etc.) by wrapping the provider and catching errors coming from the resources. This will need to remain a draft until the Go SDK Core PR and Go SDK Generator PR are merged and released.
Community Note
- Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request
Relates OR Closes #0000
Output from acceptance testing:
$ make testacc TESTARGS='-run=TestAccXXX'
...