summaryrefslogtreecommitdiff
path: root/libraries/base/System/IO/Error.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/System/IO/Error.hs')
-rw-r--r--libraries/base/System/IO/Error.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/libraries/base/System/IO/Error.hs b/libraries/base/System/IO/Error.hs
index 2de6629a89..2585181df8 100644
--- a/libraries/base/System/IO/Error.hs
+++ b/libraries/base/System/IO/Error.hs
@@ -35,6 +35,7 @@ module System.IO.Error (
isIllegalOperation,
isPermissionError,
isUserError,
+ isResourceVanishedError,
-- ** Attributes of I\/O errors
ioeGetErrorType,
@@ -60,6 +61,7 @@ module System.IO.Error (
illegalOperationErrorType,
permissionErrorType,
userErrorType,
+ resourceVanishedErrorType,
-- ** 'IOErrorType' predicates
isAlreadyExistsErrorType,
@@ -70,6 +72,7 @@ module System.IO.Error (
isIllegalOperationErrorType,
isPermissionErrorType,
isUserErrorType,
+ isResourceVanishedErrorType,
-- * Throwing and catching I\/O errors
@@ -170,6 +173,13 @@ isPermissionError = isPermissionErrorType . ioeGetErrorType
isUserError :: IOError -> Bool
isUserError = isUserErrorType . ioeGetErrorType
+-- | An error indicating that the operation failed because the
+-- resource vanished. See 'resourceVanishedErrorType'.
+--
+-- @since 0.4.14.0
+isResourceVanishedError :: IOError -> Bool
+isResourceVanishedError = isResourceVanishedErrorType . ioeGetErrorType
+
-- -----------------------------------------------------------------------------
-- IOErrorTypes
@@ -210,6 +220,14 @@ permissionErrorType = PermissionDenied
userErrorType :: IOErrorType
userErrorType = UserError
+-- | I\/O error where the operation failed because the resource vanished.
+-- This happens when, for example, attempting to write to a closed
+-- socket or attempting to write to a named pipe that was deleted.
+--
+-- @since 0.4.14.0
+resourceVanishedErrorType :: IOErrorType
+resourceVanishedErrorType = ResourceVanished
+
-- -----------------------------------------------------------------------------
-- IOErrorType predicates
@@ -258,6 +276,14 @@ isUserErrorType :: IOErrorType -> Bool
isUserErrorType UserError = True
isUserErrorType _ = False
+-- | I\/O error where the operation failed because the resource vanished.
+-- See 'resourceVanishedErrorType'.
+--
+-- @since 0.4.14.0
+isResourceVanishedErrorType :: IOErrorType -> Bool
+isResourceVanishedErrorType ResourceVanished = True
+isResourceVanishedErrorType _ = False
+
-- -----------------------------------------------------------------------------
-- Miscellaneous