Commit 046ca133 authored by Andrew Martin's avatar Andrew Martin
Browse files

Add predicates for testing if IOError is ResourceVanished.

This adds isResourceVanished, resourceVanishedErrorType, and
isResourceVanishedErrorType to System.IO.Error, resolving #14730.
parent a0e220b7
Pipeline #10161 failed with stages
in 396 minutes and 5 seconds
......@@ -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
......
......@@ -30,6 +30,9 @@
* `openTempFile` is now fully atomic and thread-safe on Windows.
* Add `isResourceVanishedError`, `resourceVanishedErrorType`, and
`isResourceVanishedErrorType` to `System.IO.Error`.
## 4.13.0.0 *TBA*
* Bundled with GHC *TBA*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment