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.
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[]
asTwitterError
? Second, would the code become more elegant by disconnecting explicitly on receivingOperationalDisconnect
?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