According to the System.Directory haddock, renameFile
may fail with a number of reasons:
A couple of these (isPermissionError, isDoesNotExistError) have testing functions, but others (including UnsupportedOperation, in which I'm interested) don't seem to correspond to anything. What is UnsupportedOperation
and how can I test for it?
More generally, how should I go about finding out what something like this is. I can't see anywhere in the source code where it's raised, so I'm guessing it's a wrapper around a lower level error - but how should I deal with those?
UnsupportedOperation
is ghc-specific. So you have to import GHC.IO.Exception
, it contains everything you need to check exception type.
Here is an example:
import Control.Exception
import GHC.IO.Exception
main :: IO ()
main = do
action `catch` (\(IOError _ UnsupportedOperation _ _ _ _) -> print "UnsupportedOperation")
where
action = throw $ IOError Nothing UnsupportedOperation "loc" "desc" Nothing Nothing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With