Enhance error handling for 403 & 404 WebApi responses #714
+226
−50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes to improve error handling in the API client by adding specific handlers for
NotFound
andForbidden
HTTP responses. These changes ensure that the client can provide more meaningful error messages when encountering these status codes. The main changes are grouped by theme as follows:Error Handling Enhancements:
internal/api/client.go
: AddedHandleNotFoundResponse
andHandleForbiddenResponse
methods to handle404 Not Found
and403 Forbidden
HTTP responses respectively.API Method Updates:
internal/services/authorization/api_user.go
: Updated multiple methods (GetDataverseUsers
,GetDataverseUserBySystemUserId
,GetDataverseUserByAadObjectId
,UpdateDataverseUser
,DeleteDataverseUser
,RemoveDataverseSecurityRoles
,AddDataverseSecurityRoles
, andGetDataverseSecurityRoles
) to include403 Forbidden
and404 Not Found
in the list of acceptable status codes and to use the new error handling methods. [1] [2] [3] [4] [5] [6] [7] [8]internal/services/data_record/api_data_record.go
: Updated multiple methods (getEntityDefinition
,GetDataRecordsByODataQuery
,GetDataRecord
,GetRelationData
,GetTableSingularNameFromPlural
,GetEntityAttributesDefinition
,GetEntityRelationDefinitionInfo
,ApplyDataRecord
,DeleteDataRecord
, andapplyRelation
) to include403 Forbidden
and404 Not Found
in the list of acceptable status codes and to use the new error handling methods. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]