diff options
author | Andrew Martin <andrew.thaddeus@gmail.com> | 2019-08-19 11:12:48 -0400 |
---|---|---|
committer | Andrew Martin <andrew.thaddeus@gmail.com> | 2019-09-13 15:43:16 -0400 |
commit | 046ca13356813af0817a7b3744315d012832fe2e (patch) | |
tree | 06ccc56443182c54e6d2c8f7406a09e2e6ed8550 /libraries/base/System | |
parent | a0e220b77957738b9966a099b5616017ab7b05b6 (diff) | |
download | haskell-046ca13356813af0817a7b3744315d012832fe2e.tar.gz |
Add predicates for testing if IOError is ResourceVanished.
This adds isResourceVanished, resourceVanishedErrorType, and
isResourceVanishedErrorType to System.IO.Error, resolving #14730.
Diffstat (limited to 'libraries/base/System')
-rw-r--r-- | libraries/base/System/IO/Error.hs | 26 |
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 |