diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-12-24 14:53:58 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-12-24 14:53:58 -0400 |
commit | 122b09e2f24cff55c65b84cbccd78ed640a234be (patch) | |
tree | 5f9f1929b2fccb9d9a783a0a53f56ba13aae7897 /Utility/Exception.hs | |
parent | 1b18f539f2bace903c853ce828902a8061007da5 (diff) | |
download | git-repair-122b09e2f24cff55c65b84cbccd78ed640a234be.tar.gz |
Merge from git-annex.
Diffstat (limited to 'Utility/Exception.hs')
-rw-r--r-- | Utility/Exception.hs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Utility/Exception.hs b/Utility/Exception.hs index 0ffc710..67c2e85 100644 --- a/Utility/Exception.hs +++ b/Utility/Exception.hs @@ -1,6 +1,6 @@ {- Simple IO exception handling (and some more) - - - Copyright 2011-2015 Joey Hess <id@joeyh.name> + - Copyright 2011-2016 Joey Hess <id@joeyh.name> - - License: BSD-2-clause -} @@ -10,6 +10,7 @@ module Utility.Exception ( module X, + giveup, catchBoolIO, catchMaybeIO, catchDefaultIO, @@ -40,6 +41,21 @@ import GHC.IO.Exception (IOErrorType(..)) import Utility.Data +{- Like error, this throws an exception. Unlike error, if this exception + - is not caught, it won't generate a backtrace. So use this for situations + - where there's a problem that the user is excpected to see in some + - circumstances. -} +giveup :: [Char] -> a +#ifdef MIN_VERSION_base +#if MIN_VERSION_base(4,9,0) +giveup = errorWithoutStackTrace +#else +giveup = error +#endif +#else +giveup = error +#endif + {- Catches IO errors and returns a Bool -} catchBoolIO :: MonadCatch m => m Bool -> m Bool catchBoolIO = catchDefaultIO False |