sledgehammer error catch, log and return nothing so that embassy remains live even if registry is unreachable

This commit is contained in:
Keagan McClelland
2021-01-18 20:53:34 -07:00
committed by Aiden McClelland
parent 408cc45688
commit d211de9782

View File

@@ -61,7 +61,9 @@ getServerR = handleS9ErrT $ do
wifi <- WpaSupplicant.runWlan0 $ liftA2 WifiList WpaSupplicant.getCurrentNetwork WpaSupplicant.listNetworks wifi <- WpaSupplicant.runWlan0 $ liftA2 WifiList WpaSupplicant.getCurrentNetwork WpaSupplicant.listNetworks
specs <- getSpecs settings specs <- getSpecs settings
welcomeAck <- fmap isJust . lift . runDB . Persist.get $ WelcomeAckKey agentVersion welcomeAck <- fmap isJust . lift . runDB . Persist.get $ WelcomeAckKey agentVersion
versionLatest <- getOSVersionLatest agentCtx versionLatest <- liftIO $ (try @SomeException $ getOSVersionLatest agentCtx) >>= \case
Left e -> (putStrLn @Text $ "Error fetching latest OS Version: " <> show e) $> Nothing
Right a -> pure a
let sid = T.drop 7 $ specsNetworkId specs let sid = T.drop 7 $ specsNetworkId specs
@@ -127,9 +129,7 @@ patchAutoCheckUpdatesR :: Handler ()
patchAutoCheckUpdatesR = do patchAutoCheckUpdatesR = do
settings <- getsYesod appSettings settings <- getsYesod appSettings
BoolPatchReq val <- requireCheckJsonBody BoolPatchReq val <- requireCheckJsonBody
runM $ runM $ injectFilesystemBaseFromContext settings $ if val
injectFilesystemBaseFromContext settings $
if val
then writeSystemPath autoCheckUpdatesPath "" then writeSystemPath autoCheckUpdatesPath ""
else deleteSystemPath autoCheckUpdatesPath else deleteSystemPath autoCheckUpdatesPath