frontend: Improve error handling in list pages #2771
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 PR combines and replaces different fields we have for error handling, currently we have 'error' 'errorMessage' 'clusterErrors' props in various places.
error
is not enough since we can have more than one errorerrorMessage
is a string and loses important context like which cluster the error is coming from and limits how we can render itclusterErrors
prop has a limitation of one error per cluster but we can have more (see Role page example)New field is
errors
an array ofApiError
ApiError is also updated to be a class instead of an interface and now contains all relevant information (if available) like cluster name, namespace of a resource and status code.
ApiError message is now also parsed from backend response (if available)
To display the error the
ClusterGroupErrorMessage
component was updated since it is already can display error.I would also change the name to something more generic like
ErrorAlerts
or something but it's not a priority.Testing done / Examples
All error messages by default are collapsed, in screenshots I'll expand them
When resource is not available, endpoint returns 404
When user doesn't have access 403
When user doesn't have access and List page loads multiple resource
Role page loads Roles and ClusterRoles
When two clusters are selected and one of them doesn't have access
When two clusters are selected and one of them doesn't have access for a List page with multiple resources
Cluster overview page with no access