summaryrefslogtreecommitdiff
path: root/Utility/Exception.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-12 14:15:28 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-12 14:16:35 -0400
commitad1955b4063befa51a36932794f49193a307a23f (patch)
treeeb358ec9eb692f4418f45ee386053e0859a1626e /Utility/Exception.hs
parent265cbb0f66881102aa11f73d0cff41c773ddb3a9 (diff)
if keys database cannot be opened due to permissions, ignore
This lets readonly repos be used. If a repo is readonly, we can ignore the keys database, because nothing that we can do will change the state of the repo anyway.
Diffstat (limited to 'Utility/Exception.hs')
-rw-r--r--Utility/Exception.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/Utility/Exception.hs b/Utility/Exception.hs
index 8b110ae6d..e691f13b6 100644
--- a/Utility/Exception.hs
+++ b/Utility/Exception.hs
@@ -21,7 +21,8 @@ module Utility.Exception (
tryNonAsync,
tryWhenExists,
catchIOErrorType,
- IOErrorType(..)
+ IOErrorType(..),
+ catchPermissionDenied,
) where
import Control.Monad.Catch as X hiding (Handler)
@@ -97,3 +98,6 @@ catchIOErrorType errtype onmatchingerr a = catchIO a onlymatching
onlymatching e
| ioeGetErrorType e == errtype = onmatchingerr e
| otherwise = throwM e
+
+catchPermissionDenied :: MonadCatch m => (IOException -> m a) -> m a -> m a
+catchPermissionDenied = catchIOErrorType PermissionDenied