Open lache-melvin opened 3 months ago
That was deliberate - we were getting duplicate errors displayed on a single page and it looks a litle incompetent, or at the least hamfisted!
If fixing, we need to be able to distinguish between multiple calls to the same action / api resulting in the same error and the user initiating something that results in the same error. possibly useQuery is initiating an action multiple times and reporting the same error multiple times?
If fixing, we need to be able to distinguish between multiple calls to the same action / api resulting in the same error and the user initiating something that results in the same error.
Hm, or a way to reset error state once the toast disappears?
Vaguely related - I've seen the multiple error toasts thing in a few places where we catch thrown errors in the calling component... i.e. API error thrown, QueryErrorHandler catches, toasts and rethrows, caught again by component, toast again - but I think that needs a separate solution
For this specific case the UI could prevent the action and give a reason why the action can't be applied.
Sorry about the chatter in the triage meeting. I was worried that we are hot fixing the problem by hiding it. If we are getting multiple errors maybe there are too many queries being executed or the error handling is not optimal (we are toasting in more then one place) ?
I was wondering what area of the app this has happened previously ?
agree - if we are still getting multiple toasts showing the same error, when the user has only done one action: then we should look at why there are so many.
I just didn't want us enabling the multi-toast again without investigating. As a general rule - the user should only be notified once of an error cause by their action. if they perform the same action again, and the error state reoccurs, sure, they should be notified again.
What went wrong? 😲
Error snack does not display again after first error:
https://github.com/msupply-foundation/open-msupply/assets/55115239/a0df8303-bbe8-4465-bc5c-b42939c6b187
This appears to be because the
QueryErrorHandler
only calls theerror
snack if itserrorMessage
reference changes. (So e.g. first error wasReturnIsNotEditable
, second error isNetworkError
, that would display fine.)The
errorMessage
state is reset when we change pages, but otherwise, if we encounter the same error message twice in a row, we will only get the snack the first time!I think this is particularly bad because the snack disappears - maybe I didn't finish reading it in time, I want to click OK again to finish reading the error message.
OR I think I fixed my entered data (but actually I hadn't fixed it, BE returning same error) so I click OK again, and now not getting any error message, but the modal won't close.
Expected behaviour 🤔
If the same problem happens twice, I am told about it twice....
How to Reproduce 🔨
Steps to reproduce the behaviour:
I think stopping the server is the easiest/fastest - but have seen with many places - with either standard errors, or where we throw errors from the api.ts files...
NetworkError
OR: this is what I did for the video:
ReturnIsNotEditable
Your environment 🌱