Skip to content

api: Make a structured exception type for API errors, and use it #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gnprice opened this issue Mar 30, 2023 · 1 comment · Fixed by #113
Closed

api: Make a structured exception type for API errors, and use it #37

gnprice opened this issue Mar 30, 2023 · 1 comment · Fixed by #113
Labels
a-api Implementing specific parts of the Zulip server API

Comments

@gnprice
Copy link
Member

gnprice commented Mar 30, 2023

Like the ApiError and its base class RequestError that we have in the RN app in src/api/apiErrors.js.

@chrisbobbe
Copy link
Collaborator

chrisbobbe commented May 2, 2023

Some API errors are for conditions that we'll want to recognize as fatal to the current API connection: the user's auth credential was invalidated, the realm or user was deactivated (see zulip/zulip-mobile#4571), possibly more. (Maybe the invalid-event-queue error?)

When working on this issue, I wonder if we need to think about those API errors differently than more mundane ones, like when you tried to send a message with a too-long topic.

gnprice added a commit to gnprice/zulip-flutter that referenced this issue May 24, 2023
These are quite a lot like the ones we have in zulip-mobile,
defined in `src/api/apiErrors.js` there.  The main differences are:

 * Each exception has a `routeName` property, to identify what route
   was involved.  This is information that can be quite helpful in
   debugging; and while it should typically be possible to work it out
   from looking at the stack, it's nicer to be explicit.

 * The exception types are named like FooException, whereas they're
   FooError in zulip-mobile.  This is just to conform to Dart
   convention, where there's an Exception type and an Error type,
   and these are definitely Exception and not Error because they
   don't necessarily represent any bug in the program.

Fixes: zulip#37
@gnprice gnprice added the a-api Implementing specific parts of the Zulip server API label Jun 14, 2023
@gnprice gnprice moved this to Done in Flutter app Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-api Implementing specific parts of the Zulip server API
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants