Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sven Tennie
exceptions
Commits
4b18de03
Commit
4b18de03
authored
Oct 21, 2021
by
Sven Tennie
😺
Browse files
Replace SomeException with SomeExceptionWithBacktrace (#18159)
parent
ebc21bd7
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Control/Monad/Catch.hs
View file @
4b18de03
...
...
@@ -74,10 +74,15 @@ module Control.Monad.Catch (
,
bracketOnError
-- * Re-exports from Control.Exception
,
Exception
(
..
)
,
SomeException
(
..
)
,
SomeException
WithBacktrace
(
..
)
)
where
import
Control.Exception
(
Exception
(
..
),
SomeException
(
..
))
import
Control.Exception
(
Exception
(
..
))
#
if
__GLASGOW_HASKELL__
>=
903
import
Control.Exception
(
SomeExceptionWithBacktrace
(
..
))
#
else
import
Control.Exception
(
SomeException
(
..
))
#
endif
import
qualified
Control.Exception
as
ControlException
import
qualified
Control.Monad.STM
as
STM
import
qualified
Control.Monad.Trans.RWS.Lazy
as
LazyRWS
...
...
@@ -118,6 +123,10 @@ import Data.Monoid
import
Control.Applicative
#
endif
#
if
__GLASGOW_HASKELL__
<
903
type
SomeExceptionWithBacktrace
=
SomeException
#
endif
------------------------------------------------------------------------------
-- $mtl
-- The mtl style typeclass
...
...
@@ -316,7 +325,7 @@ class MonadCatch m => MonadMask m where
-- ('ExitCaseAbort').
data
ExitCase
a
=
ExitCaseSuccess
a
|
ExitCaseException
SomeException
|
ExitCaseException
SomeException
WithBacktrace
|
ExitCaseAbort
deriving
Show
...
...
@@ -350,17 +359,17 @@ instance MonadThrow STM where
instance
MonadCatch
STM
where
catch
=
STM
.
catchSTM
instance
e
~
SomeException
=>
MonadThrow
(
Either
e
)
where
instance
e
~
SomeException
WithBacktrace
=>
MonadThrow
(
Either
e
)
where
throwM
=
Left
.
toException
-- | @since 0.8.3
instance
e
~
SomeException
=>
MonadCatch
(
Either
e
)
where
instance
e
~
SomeException
WithBacktrace
=>
MonadCatch
(
Either
e
)
where
catch
(
Left
e
)
f
=
case
fromException
e
of
Nothing
->
Left
e
Just
e'
->
f
e'
catch
x
@
(
Right
_
)
_
=
x
-- | @since 0.8.3
instance
e
~
SomeException
=>
MonadMask
(
Either
e
)
where
instance
e
~
SomeException
WithBacktrace
=>
MonadMask
(
Either
e
)
where
mask
f
=
f
id
uninterruptibleMask
f
=
f
id
...
...
@@ -740,7 +749,7 @@ uninterruptibleMask_ io = uninterruptibleMask $ \_ -> io
--
-- /NOTE/ This catches all /exceptions/, but if the monad supports other ways of
-- aborting the computation, those other kinds of errors will not be caught.
catchAll
::
MonadCatch
m
=>
m
a
->
(
SomeException
->
m
a
)
->
m
a
catchAll
::
MonadCatch
m
=>
m
a
->
(
SomeException
WithBacktrace
->
m
a
)
->
m
a
catchAll
=
catch
-- | Catch all 'IOError' (eqv. 'IOException') exceptions. Still somewhat too
...
...
@@ -771,7 +780,7 @@ handleIOError :: MonadCatch m => (IOError -> m a) -> m a -> m a
handleIOError
=
handle
-- | Flipped 'catchAll'
handleAll
::
MonadCatch
m
=>
(
SomeException
->
m
a
)
->
m
a
->
m
a
handleAll
::
MonadCatch
m
=>
(
SomeException
WithBacktrace
->
m
a
)
->
m
a
->
m
a
handleAll
=
handle
-- | Flipped 'catchIf'
...
...
src/Control/Monad/Catch/Pure.hs
View file @
4b18de03
...
...
@@ -91,11 +91,11 @@ import Data.Traversable as Traversable
-- >>> runCatchT $ (throwM (ErrorCall "Hello!") :: CatchT IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)
-- Hello!
newtype
CatchT
m
a
=
CatchT
{
runCatchT
::
m
(
Either
SomeException
a
)
}
newtype
CatchT
m
a
=
CatchT
{
runCatchT
::
m
(
Either
SomeException
WithBacktrace
a
)
}
type
Catch
=
CatchT
Identity
runCatch
::
Catch
a
->
Either
SomeException
a
runCatch
::
Catch
a
->
Either
SomeException
WithBacktrace
a
runCatch
=
runIdentity
.
runCatchT
instance
Monad
m
=>
Functor
(
CatchT
m
)
where
...
...
@@ -212,7 +212,7 @@ instance MonadRWS r w s m => MonadRWS r w s (CatchT m)
-- | Map the unwrapped computation using the given function.
--
-- @'runCatchT' ('mapCatchT' f m) = f ('runCatchT' m)@
mapCatchT
::
(
m
(
Either
SomeException
a
)
->
n
(
Either
SomeException
b
))
mapCatchT
::
(
m
(
Either
SomeException
WithBacktrace
a
)
->
n
(
Either
SomeException
WithBacktrace
b
))
->
CatchT
m
a
->
CatchT
n
b
mapCatchT
f
m
=
CatchT
$
f
(
runCatchT
m
)
tests/Control/Monad/Catch/Tests.hs
View file @
4b18de03
...
...
@@ -120,7 +120,7 @@ tests = testGroup "Control.Monad.Catch.Tests" $
--, SomeMSpec mspecContTIO
,
SomeMSpec
mspecCatchTIdentity
,
SomeMSpec
mspecEitherSomeException
,
SomeMSpec
mspecEitherSomeException
WithBacktrace
]
mspecIO
::
MSpec
IO
...
...
@@ -168,8 +168,8 @@ tests = testGroup "Control.Monad.Catch.Tests" $
mspecCatchTIdentity
::
MSpec
Catch
mspecCatchTIdentity
=
MSpec
"Catch"
$
fromRight
.
runCatch
mspecEitherSomeException
::
MSpec
(
Either
SomeException
)
mspecEitherSomeException
=
MSpec
"Either SomeException"
fromRight
mspecEitherSomeException
WithBacktrace
::
MSpec
(
Either
SomeException
WithBacktrace
)
mspecEitherSomeException
WithBacktrace
=
MSpec
"Either SomeException
WithBacktrace
"
fromRight
tfst
::
(
Property
,
()
)
->
Property
=
fst
fromRight
(
Left
_
)
=
error
"fromRight"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment