Better error handling for various edge cases (like 404s from deleting non-existent records)
Observed behavior
Here are some places where we could replace the catch-all 'AppError' (appears with 'handleApiError' dispatches) with in-UI error messages (or no error at all).
- ~Deleting a user from the facility when that user has already been deleted. (No error should be shown)~
- Deleting a class that has already been deleted
- ~Visiting a Coach link for a class that has been deleted (it's handled like a 403 error)~
- ~Repeat for the various other things that can be deleted in Kolibri, as these will all lead to 404 errors of some kind.~
- ~Assigning an existing user a username that has already been given (by another user in another session, for example)~
- ~Creating a new user in a similar situation as above. There is incorrect logic that is intended to handle this in UserCreateModal (but the code incorrect, so this situation ends up showing the AppError page)~
- Attempting to access a classroom page when you are a coach not assigned to the classroom.
- ~Attempting to view a Classroom List or Assignments page as a Learner when not logged in (#5360 )~
These errors fall into several broad categories:
- Attempting access a non-existent object (e.g. because it's been deleted or a UUID has been mis-typed). Issue #5666
- Attempting to modify a deleted object
- Attempting to delete a deleted object
- Attempting to create an object, and the new object violates some rule (e.g. unique name)
- Attempting to access an object for which you don't have the proper permissions.
In general, look where handleApiError is used and ask whether this can be replaced with no error, or an error placed within the current UI.
Expected behavior
In the edge cases described above, errors are handled as prescribed.
User-facing consequences
…
Errors and logs
…
Steps to reproduce
…
Context
…
do these situations need design and/or user-facing strings?
Some of these don't require any new UI, like deleting something that's already deleted. (e.g. if you deleted an already-deleted faciltiyuser, dont show an error, remove the facilityuser from the table, the app user doesn't need to see anything).
We don't handle going to links for non-existent things (e.g. visiting a class homepage for deleted class), so that will require new design and strings.
I've asked @MisRob if she can look for more overlooked edge cases to complete the list in the OP, and then maybe we can handle the different categories in more depth, design-wise.
https://docs.google.com/document/d/1LNAwzu_hgXQtGh-IMz_A1IsN4CdCGDIcTMcxowiS9Tg/edit?usp=sharing
Unhandled 404 errors are also flooding Sentry with spurious errors
another instance: https://github.com/learningequality/kolibri/issues/5801