api: Include stack trace when reporting MalformedServerResponseException
Fixes: #1083
Changes:
- Add
causeStackTracefield toMalformedServerResponseException - Include stack trace in the exception's
toString()output - Add test to verify stack trace is included in error messages
Testing:
- Added unit test that verifies stack trace is included when a type mismatch occurs
- Manually tested with registerQueue to confirm stack trace shows in error dialog
Screenshot of error
It doesn't look like this new parameter causeStackTrace ever gets passed to the constructor. So it doesn't actually do anything in the live app.
Please test your change end to end in the app, and revise it so it solves the problem described in the issue:
When a request to the server fails, we typically show an error to the user. (The main gap in that is https://github.com/zulip/zulip-flutter/issues/890, which we should fix.) The details of the error can be useful, particularly if the user takes a screenshot of them to include in reporting the issue to us.
If the cause of the error is that the server's response doesn't match our expectations — a MalformedServerResponseException — then a key thing we want to know is where in the schema the mismatch occurred: what field of what type of object. […] So we should show the stack trace when reporting a MalformedServerResponseException.
Hi @PIG208, whenever you get a chance, could you please take a look at my PR for an initial review? Thanks!
Hi @PIG208, thanks for the above reviews. I have pushed the revision. PTAL.
Thanks for the update! Left some comments.
Hi @PIG208, thanks for the review. I have pushed the revision. PTAL!
Hi @PIG208 , whenever you get some time, please take a look at the PR. Thanks!
Hi @PIG208, I have pushed the revision PTAL, Thanks!
Hi @PIG208, I have pushed the revision as well as updates the PR description with the screenshot of error. PTAL, thanks!
One other note: I think I wasn't clear in my previous #1374 (review) that I was referring to taking a screenshot of the error the user might see while using the app.
Should I add a snackbar or dailogbox in the app to show error to the user on the app screen?
I think we shouldn't need to add a snack bar/dialog, since the error should have been handled from the polling loop in UpdateMachine.
Such an error might look like this:
As @PIG208 said above, I think we shouldn't need to add any new snack bar or dialog in order for the error to get shown to the user — the existing error dialog should do it.
But as the issue #1083 says, and as I emphasized in https://github.com/zulip/zulip-flutter/pull/1374#issuecomment-2679677776 at the top of this thread, the point of the issue is about what information we show to the user.
So, does this PR cause the stack trace to get shown to the user when they hit one of these errors? Please post a screenshot of what that looks like.
(The PR description currently has a screenshot of something shown in your terminal, as a developer. That isn't informative about what the user sees. If it were relevant information, then copy-paste into a code block would be a clearer way to present it than a screenshot.)
Hi @lakshya1goel, please let us know if you're planning to update this following Greg's comment above.
We've resolved this issue, in #1949, so closing this PR.