Skip to content

Commit bc7c5bb

Browse files
committed
Print Servant errors when getUpdates fails
1 parent 33bb851 commit bc7c5bb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Telegram/Bot/Simple.hs

+9-2
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,19 @@ startPolling handleUpdate = go Nothing
116116
go lastUpdateId = do
117117
let inc (UpdateId n) = UpdateId (n + 1)
118118
offset = fmap inc lastUpdateId
119-
res <- try $ getUpdates (GetUpdatesRequest offset Nothing Nothing Nothing)
119+
res <- try $
120+
(Right <$> getUpdates
121+
(GetUpdatesRequest offset Nothing Nothing Nothing))
122+
`catchError` (pure . Left)
123+
120124
nextUpdateId <- case res of
121125
Left (ex :: SomeException) -> do
122126
liftIO (print ex)
123127
pure lastUpdateId
124-
Right result -> do
128+
Right (Left servantErr) -> do
129+
liftIO (print servantErr)
130+
pure lastUpdateId
131+
Right (Right result) -> do
125132
let updates = responseResult result
126133
updateIds = map updateUpdateId updates
127134
maxUpdateId = maximum (Nothing : map Just updateIds)

0 commit comments

Comments
 (0)