Skip to content
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

Handle .errors[] in streams #94

Open
1 task done
arty-name opened this issue Oct 28, 2021 · 0 comments
Open
1 task done

Handle .errors[] in streams #94

arty-name opened this issue Oct 28, 2021 · 0 comments

Comments

@arty-name
Copy link

Prerequisites

Summary

Some chunks coming from the stream API look like the example below.
First, would it make sense to report whatever is coming in .errors[] as TwitterError?
Second, would the code become more elegant by disconnecting explicitly on receiving OperationalDisconnect?

const chunk = {
  errors: [
    {
      title: 'operational-disconnect',
      disconnect_type: 'OperationalDisconnect',
      detail: 'This stream has been disconnected for operational reasons.',
      type: 'https://api.twitter.com/2/problems/operational-disconnect',
    },
  ],
}

Motivation

My code was naively expecting to receive consistently formed chunks and errored out on this unexpected shape. Which is kind of fine, but since this is an explicit error, it probably would make sense to centralize its handling in the twitter-v2.

Describe alternatives you've considered

Leaving this for all library users to handle by themselves is also an option, a wasteful one though.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant