-#endif
-
--- | tryUser is like try, but catches only UserErrors.
--- These are the ones that are thrown by the TcRn monad
--- to signal an error in the program being compiled
-#if __GLASGOW_HASKELL__ < 609
-tryUser :: IO a -> IO (Either Exception.Exception a)
-tryUser action = tryJust tc_errors action
- where
- tc_errors e@(Exception.IOException ioe) | isUserError ioe = Just e
- tc_errors _other = Nothing
-#else
-tryUser :: IO a -> IO (Either IOException a)
-tryUser io =
- do ei <- try io
- case ei of
- Right v -> return (Right v)
- Left se@(SomeException ex) ->
- case cast ex of
- Just ioe
- | isUserError ioe ->
- return (Left ioe)
- _ -> throw se
-#endif