Ignore throttling
I'll have to find a better way to tell the client that it is being throttled.
This commit is contained in:
parent
f0c9f92d44
commit
5709d1aeec
1 changed files with 5 additions and 13 deletions
|
|
@ -88,11 +88,9 @@ instance FromJSON Event where
|
||||||
]
|
]
|
||||||
|
|
||||||
data ClientException e
|
data ClientException e
|
||||||
= ServerException (Maybe T.Text) (Maybe T.Text)
|
= ServerException T.Text
|
||||||
-- ^ @'ServerError' error throttled@ is an error sent by the server in
|
-- ^ @'ServerError' error@ is an error sent by the server in response to a
|
||||||
-- response to a command. @error@ is a message that appears if a command
|
-- command. @error@ is a message that appears if a command fails.
|
||||||
-- fails. @throttled@ is a message that appears if the client should slow down
|
|
||||||
-- its command rate.
|
|
||||||
| StoppedException
|
| StoppedException
|
||||||
| DecodeException T.Text
|
| DecodeException T.Text
|
||||||
-- ^ At some point during decoding a websocket packet, something went wrong.
|
-- ^ At some point during decoding a websocket packet, something went wrong.
|
||||||
|
|
@ -103,14 +101,8 @@ data ClientException e
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
instance FromJSON (ClientException e) where
|
instance FromJSON (ClientException e) where
|
||||||
parseJSON (Object o) = do
|
parseJSON (Object o) = ServerException
|
||||||
serverError <- o .:? "error"
|
<$> o .: "error"
|
||||||
isThrottled <- o .:? "throttled" .!= False
|
|
||||||
throttledReason <- o .:? "throttled_reason"
|
|
||||||
let throttled = if isThrottled then Just (fromMaybe "" throttledReason) else Nothing
|
|
||||||
when (isNothing serverError && isNothing throttled) $
|
|
||||||
fail "there is no error and the client is not throttled"
|
|
||||||
pure $ ServerException serverError throttled
|
|
||||||
parseJSON v = typeMismatch "Object" v
|
parseJSON v = typeMismatch "Object" v
|
||||||
|
|
||||||
-- | This type is used by the websocket thread to send the server's replies to
|
-- | This type is used by the websocket thread to send the server's replies to
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue