Skip to content

Commit

Permalink
Print Servant errors when getUpdates fails
Browse files Browse the repository at this point in the history
  • Loading branch information
fizruk committed Jun 3, 2018
1 parent 33bb851 commit bc7c5bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Telegram/Bot/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,19 @@ startPolling handleUpdate = go Nothing
go lastUpdateId = do
let inc (UpdateId n) = UpdateId (n + 1)
offset = fmap inc lastUpdateId
res <- try $ getUpdates (GetUpdatesRequest offset Nothing Nothing Nothing)
res <- try $
(Right <$> getUpdates
(GetUpdatesRequest offset Nothing Nothing Nothing))
`catchError` (pure . Left)

nextUpdateId <- case res of
Left (ex :: SomeException) -> do
liftIO (print ex)
pure lastUpdateId
Right result -> do
Right (Left servantErr) -> do
liftIO (print servantErr)
pure lastUpdateId
Right (Right result) -> do
let updates = responseResult result
updateIds = map updateUpdateId updates
maxUpdateId = maximum (Nothing : map Just updateIds)
Expand Down

0 comments on commit bc7c5bb

Please sign in to comment.