-{-# OPTIONS_GHC -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -XNoImplicitPrelude #-}
-----------------------------------------------------------------------------
-- |
module System.IO.Error (
-- * I\/O errors
- IOError, -- = IOException
+ IOError, -- = IOException
- userError, -- :: String -> IOError
+ userError, -- :: String -> IOError
#ifndef __NHC__
- mkIOError, -- :: IOErrorType -> String -> Maybe Handle
- -- -> Maybe FilePath -> IOError
+ mkIOError, -- :: IOErrorType -> String -> Maybe Handle
+ -- -> Maybe FilePath -> IOError
- annotateIOError, -- :: IOError -> String -> Maybe Handle
- -- -> Maybe FilePath -> IOError
+ annotateIOError, -- :: IOError -> String -> Maybe Handle
+ -- -> Maybe FilePath -> IOError
#endif
-- ** Classifying I\/O errors
- isAlreadyExistsError, -- :: IOError -> Bool
+ isAlreadyExistsError, -- :: IOError -> Bool
isDoesNotExistError,
isAlreadyInUseError,
isFullError,
-- ** Attributes of I\/O errors
#ifndef __NHC__
- ioeGetErrorType, -- :: IOError -> IOErrorType
+ ioeGetErrorType, -- :: IOError -> IOErrorType
+ ioeGetLocation, -- :: IOError -> String
#endif
- ioeGetErrorString, -- :: IOError -> String
- ioeGetHandle, -- :: IOError -> Maybe Handle
- ioeGetFileName, -- :: IOError -> Maybe FilePath
+ ioeGetErrorString, -- :: IOError -> String
+ ioeGetHandle, -- :: IOError -> Maybe Handle
+ ioeGetFileName, -- :: IOError -> Maybe FilePath
#ifndef __NHC__
- ioeSetErrorType, -- :: IOError -> IOErrorType -> IOError
- ioeSetErrorString, -- :: IOError -> String -> IOError
- ioeSetHandle, -- :: IOError -> Handle -> IOError
- ioeSetFileName, -- :: IOError -> FilePath -> IOError
+ ioeSetErrorType, -- :: IOError -> IOErrorType -> IOError
+ ioeSetErrorString, -- :: IOError -> String -> IOError
+ ioeSetLocation, -- :: IOError -> String -> IOError
+ ioeSetHandle, -- :: IOError -> Handle -> IOError
+ ioeSetFileName, -- :: IOError -> FilePath -> IOError
#endif
-- * Types of I\/O error
- IOErrorType, -- abstract
+ IOErrorType, -- abstract
- alreadyExistsErrorType, -- :: IOErrorType
+ alreadyExistsErrorType, -- :: IOErrorType
doesNotExistErrorType,
alreadyInUseErrorType,
fullErrorType,
userErrorType,
-- ** 'IOErrorType' predicates
- isAlreadyExistsErrorType, -- :: IOErrorType -> Bool
+ isAlreadyExistsErrorType, -- :: IOErrorType -> Bool
isDoesNotExistErrorType,
isAlreadyInUseErrorType,
isFullErrorType,
-- * Throwing and catching I\/O errors
- ioError, -- :: IOError -> IO a
+ ioError, -- :: IOError -> IO a
- catch, -- :: IO a -> (IOError -> IO a) -> IO a
- try, -- :: IO a -> IO (Either IOError a)
+ catch, -- :: IO a -> (IOError -> IO a) -> IO a
+ try, -- :: IO a -> IO (Either IOError a)
#ifndef __NHC__
- modifyIOError, -- :: (IOError -> IOError) -> IO a -> IO a
+ modifyIOError, -- :: (IOError -> IOError) -> IO a -> IO a
#endif
) where
+import {-# SOURCE #-} Prelude (catch)
+
import Data.Either
import Data.Maybe
#ifdef __GLASGOW_HASKELL__
import GHC.Base
import GHC.IOBase
-import GHC.Exception
import Text.Show
#endif
, try
, ioError
, userError
- , isAlreadyExistsError -- :: IOError -> Bool
+ , isAlreadyExistsError -- :: IOError -> Bool
, isDoesNotExistError
, isAlreadyInUseError
, isFullError
mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError
mkIOError t location maybe_hdl maybe_filename =
IOError{ ioe_type = t,
- ioe_location = location,
- ioe_description = "",
- ioe_handle = maybe_hdl,
- ioe_filename = maybe_filename
- }
+ ioe_location = location,
+ ioe_description = "",
+ ioe_handle = maybe_hdl,
+ ioe_filename = maybe_filename
+ }
#ifdef __NHC__
mkIOError EOF location maybe_hdl maybe_filename =
EOFError location (fromJust maybe_hdl)
#ifdef __NHC__
data IOErrorType = AlreadyExists | NoSuchThing | ResourceBusy
- | ResourceExhausted | EOF | IllegalOperation
- | PermissionDenied | UserError
+ | ResourceExhausted | EOF | IllegalOperation
+ | PermissionDenied | UserError
#endif
-- | I\/O error where the operation failed because one of its arguments
permissionErrorType = PermissionDenied
-- | I\/O error that is programmer-defined.
-userErrorType :: IOErrorType
-userErrorType = UserError
+userErrorType :: IOErrorType
+userErrorType = UserError
-- -----------------------------------------------------------------------------
-- IOErrorType predicates
-- Miscellaneous
#if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
-ioeGetErrorType :: IOError -> IOErrorType
+ioeGetErrorType :: IOError -> IOErrorType
ioeGetErrorString :: IOError -> String
+ioeGetLocation :: IOError -> String
ioeGetHandle :: IOError -> Maybe Handle
ioeGetFileName :: IOError -> Maybe FilePath
| isUserErrorType (ioe_type ioe) = ioe_description ioe
| otherwise = show (ioe_type ioe)
+ioeGetLocation ioe = ioe_location ioe
+
ioeGetHandle ioe = ioe_handle ioe
ioeGetFileName ioe = ioe_filename ioe
-ioeSetErrorType :: IOError -> IOErrorType -> IOError
-ioeSetErrorString :: IOError -> String -> IOError
-ioeSetHandle :: IOError -> Handle -> IOError
-ioeSetFileName :: IOError -> FilePath -> IOError
+ioeSetErrorType :: IOError -> IOErrorType -> IOError
+ioeSetErrorString :: IOError -> String -> IOError
+ioeSetLocation :: IOError -> String -> IOError
+ioeSetHandle :: IOError -> Handle -> IOError
+ioeSetFileName :: IOError -> FilePath -> IOError
ioeSetErrorType ioe errtype = ioe{ ioe_type = errtype }
ioeSetErrorString ioe str = ioe{ ioe_description = str }
+ioeSetLocation ioe str = ioe{ ioe_location = str }
ioeSetHandle ioe hdl = ioe{ ioe_handle = Just hdl }
ioeSetFileName ioe filename = ioe{ ioe_filename = Just filename }