Error manipulation functions

Ian Lynagh igloo at earth.li
Thu Jul 28 10:05:06 EDT 2005


Hi all,

I couldn't see a way to write any of these functions without using
GHC.IOBase. Did I miss one?

If not, can they (or something that would allow them to be written)
please be added to System.IO.Error?


import GHC.IOBase ( IOException(ioe_location),
                    IOErrorType(UnsupportedOperation, HardwareFault) )

add_to_error_loc :: Exception -> String -> Exception
add_to_error_loc (IOException ioe) s
    = IOException $ ioe { ioe_location = s ++ ": " ++ ioe_location ioe }
add_to_error_loc e _ = e

isUnsupportedOperationError :: IOError -> Bool
isUnsupportedOperationError = isUnsupportedOperationErrorType . ioeGetErrorType

isUnsupportedOperationErrorType :: IOErrorType -> Bool
isUnsupportedOperationErrorType UnsupportedOperation = True
isUnsupportedOperationErrorType _ = False


Thanks
Ian



More information about the Libraries mailing list