ADD error message for device init

This commit is contained in:
Nathan Dwarshuis 2023-01-01 21:36:16 -05:00
parent 7432a8f841
commit 2948610785
1 changed files with 12 additions and 4 deletions

View File

@ -206,7 +206,12 @@ addDeviceRemovedListener state dpy adapter sys =
old <- removeDevice state d old <- removeDevice state d
forM_ old $ liftIO . removeMatch (toClient sys) . btDevSigHandler forM_ old $ liftIO . removeMatch (toClient sys) . btDevSigHandler
pathCallback :: MonadUnliftIO m => ObjectPath -> m () -> (ObjectPath -> m ()) -> SignalCallback m pathCallback
:: MonadUnliftIO m
=> ObjectPath
-> m ()
-> (ObjectPath -> m ())
-> SignalCallback m
pathCallback adapter dpy f [device, _] = forM_ (fromVariant device) $ \d -> pathCallback adapter dpy f [device, _] = forM_ (fromVariant device) $ \d ->
when (adaptorHasDevice adapter d) $ f d >> dpy when (adaptorHasDevice adapter d) $ f d >> dpy
pathCallback _ _ _ _ = return () pathCallback _ _ _ _ = return ()
@ -303,9 +308,12 @@ addAndInitDevice
-> SysClient -> SysClient
-> m () -> m ()
addAndInitDevice state dpy device client = do addAndInitDevice state dpy device client = do
sh <- addDeviceListener state dpy device client res <- addDeviceListener state dpy device client
-- TODO add some intelligent error messages here case res of
forM_ sh $ \s -> initDevice state s device client Just handler -> initDevice state handler device client
Nothing -> logError $ "could not initialize device at path " <> device_
where
device_ = displayWrapQuote $ displayObjectPath device
initDevice initDevice
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m) :: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)