File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
cardano-api/src/Cardano/Api Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change 77-- | Class of errors used in the Api.
88module Cardano.Api.Error
99 ( Error (.. )
10- , throwErrorAsException
10+ , throwErrorM
1111 , liftEitherError
1212 , failEitherError
1313 , ErrorAsException (.. )
@@ -32,24 +32,15 @@ class Error e where
3232instance Error () where
3333 prettyError () = " "
3434
35- -- | The preferred approach is to use 'Except' or 'ExceptT', but you can if
36- -- necessary use IO exceptions.
37- throwErrorAsException
35+ -- | Throw an 'Error e' as 'ErrorAsException'. 'throwErrorM' will attach a call stack to the exception.
36+ throwErrorM
3837 :: HasCallStack
3938 => MonadThrow m
4039 => Typeable e
4140 => Error e
4241 => e
4342 -> m a
44- throwErrorAsException e = withFrozenCallStack $ throwM $ ErrorAsException e
45-
46- -- | Pretty print 'Error e' and 'fail' if 'Left'.
47- failEitherError
48- :: MonadFail m
49- => Error e
50- => Either e a
51- -> m a
52- failEitherError = failEitherWith displayError
43+ throwErrorM e = withFrozenCallStack $ throwM $ ErrorAsException e
5344
5445-- | Pretty print 'Error e' and 'throwM' it wrapped in 'ErrorAsException' when 'Left'.
5546liftEitherError
@@ -59,7 +50,15 @@ liftEitherError
5950 => Error e
6051 => Either e a
6152 -> m a
62- liftEitherError = withFrozenCallStack $ either throwErrorAsException pure
53+ liftEitherError = withFrozenCallStack $ either throwErrorM pure
54+
55+ -- | Pretty print 'Error e' and 'fail' if 'Left'.
56+ failEitherError
57+ :: MonadFail m
58+ => Error e
59+ => Either e a
60+ -> m a
61+ failEitherError = failEitherWith displayError
6362
6463-- | An exception wrapping any 'Error e', attaching a call stack from the construction place to it.
6564data ErrorAsException where
You can’t perform that action at this time.
0 commit comments