This pull request primarily addresses error handling and reporting in the Power Platform API client and related services. The changes involve the addition of a new error code ERROR_ENVIRONMENT_URL_NOT_FOUND, and checks for empty environment URLs in various methods across different services. If an environment URL is found to be empty, the new error is raised with a helpful message. This error is then handled in the Read methods of EnvironmentResource and EnvironmentsDataSource, where a warning is added to the diagnostics only if the error is not ERROR_ENVIRONMENT_URL_NOT_FOUND.
internal/powerplatform/services/authorization/api_user.go, internal/powerplatform/services/data_record/api_data_record.go, internal/powerplatform/services/environment/api_environment.go, internal/powerplatform/services/environment_settings/api_environment_settings.go, and internal/powerplatform/services/solution/api_solution.go: In the GetEnvironmentUrlById method, added a check for empty environmentUrl. If empty, it now returns the new ERROR_ENVIRONMENT_URL_NOT_FOUND error. [1][2][3][4][5]
Error handling in data sources and resources:
internal/powerplatform/services/environment/datasource_environments.go and internal/powerplatform/services/environment/resource_environment.go: In the Read method, added a condition to only add a warning to the diagnostics if the error is not ERROR_ENVIRONMENT_URL_NOT_FOUND. [1][2]
Imports:
internal/powerplatform/services/environment/datasource_environments.go, internal/powerplatform/services/environment/resource_environment.go, and internal/powerplatform/services/environment_settings/api_environment_settings.go: Added import for helpers to use the new error code. [1][2][3]
This pull request primarily addresses error handling and reporting in the Power Platform API client and related services. The changes involve the addition of a new error code
ERROR_ENVIRONMENT_URL_NOT_FOUND
, and checks for empty environment URLs in various methods across different services. If an environment URL is found to be empty, the new error is raised with a helpful message. This error is then handled in theRead
methods ofEnvironmentResource
andEnvironmentsDataSource
, where a warning is added to the diagnostics only if the error is notERROR_ENVIRONMENT_URL_NOT_FOUND
.Here are the most important changes:
New error code:
internal/powerplatform/helpers/error.go
: Added a new error codeERROR_ENVIRONMENT_URL_NOT_FOUND
.Error handling in API client and services:
internal/powerplatform/api/api_client.go
: Added extra empty lines for code readability.internal/powerplatform/services/authorization/api_user.go
,internal/powerplatform/services/data_record/api_data_record.go
,internal/powerplatform/services/environment/api_environment.go
,internal/powerplatform/services/environment_settings/api_environment_settings.go
, andinternal/powerplatform/services/solution/api_solution.go
: In theGetEnvironmentUrlById
method, added a check for emptyenvironmentUrl
. If empty, it now returns the newERROR_ENVIRONMENT_URL_NOT_FOUND
error. [1] [2] [3] [4] [5]Error handling in data sources and resources:
internal/powerplatform/services/environment/datasource_environments.go
andinternal/powerplatform/services/environment/resource_environment.go
: In theRead
method, added a condition to only add a warning to the diagnostics if the error is notERROR_ENVIRONMENT_URL_NOT_FOUND
. [1] [2]Imports:
internal/powerplatform/services/environment/datasource_environments.go
,internal/powerplatform/services/environment/resource_environment.go
, andinternal/powerplatform/services/environment_settings/api_environment_settings.go
: Added import forhelpers
to use the new error code. [1] [2] [3]