
Brandon writes:
On Thu, Dec 31, 2015 at 5:53 PM, Adam Sjøgren
wrote:
-- manage a new window handle (MapRequestEvent {ev_window = w}) = withDisplay $ \dpy -> do wa <- io $ getWindowAttributes dpy w -- ignore override windows -- need to ignore mapping requests by managed windows not on the current workspace managed <- isClient w when (not (wa_override_redirect wa) && not managed) $ do manage w
What needs to happen is that I need to wrap this, so if getWindowAttributes throws an exception, something reasonable happens.
What exceptions are you expecting? The only one I'd expect is no such window, in which case you kinda want to abort anyway.
I have put a "putStrLn" in before each call to getWindowAttributes in my local XMonad, and I am recording every time it crashes, so I am not expecting an exception in this place, I had one! Just aborting altogether I think I can manage - I will give it a shot. Thanks!
I've tried a number of combinations of wrapping C.handle around this, similar to what I have found before², but I certainly need (to read a lot more, or, some) help - I keep getting IO () when I need X (), or the opposite, and stuff like that.
http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchX to catch exceptions from code producing X something. http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchIO to catch exceptions from code producing IO something.
(Don't feel too bad about this, it's actually a surprisingly hard problem in the general case. MonadBaseControl grew out of trying to deal with it in various situations, because it's hard to do "catch" properly in a monad over IO and impossible to do "bracket" properly. Specific cases can be done, as above catchX / catchIO, but even then require some thinking to write in the first place.)
(Given how low I am on the understanding-ladder, I don't feel bad at all - I've just come to realize that I need to solve "real" problems to get anywhere, but sometimes I get stuck, and sometimes I am too lazy to loop back to reading up on Haskell, so I ask instead. Thanks for helping!) Best regards, Adam -- "They misunderestimated me." Adam Sjøgren asjo@koldfront.dk