Skip to content

Commit

Permalink
Cleanup error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
supersven committed Oct 1, 2024
1 parent f13a8b3 commit da83c3f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/db/find-undead/src/Work.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ import Wire.API.User (AccountStatus (..))

runCommand :: Logger -> ClientState -> ES.BHEnv -> String -> IO ()
runCommand l cas es indexStr = do
let index = fromRight (error "TODO: Index error helper function") $ ES.mkIndexName $ Text.pack indexStr
transform :: IO (Either ES.EsError a) -> IO a
transform = fmap (fromRight (error "TODO: Handle error"))
index <-
either (\err -> fail ("Invalid index name: " ++ indexStr ++ ". Error: " ++ show err)) pure $
ES.mkIndexName $
Text.pack indexStr
let transform :: IO (Either ES.EsError a) -> IO a
transform res =
res
>>= \r -> either (\err -> (fail ("ElasticSearch error: " ++ show err))) pure r
runConduit $
transPipe (transform <$> ES.runBH es) $
getScrolled index
Expand Down

0 comments on commit da83c3f

Please sign in to comment.