Skip to content

Commit c2cf462

Browse files
authored
Merge pull request #1032 from IntersectMBO/mgalazyn/chore/rename-throwerrorasexception
Rename throwErrorAsException to throwErrorM
2 parents a58eab7 + 4eb0192 commit c2cf462

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

cardano-api/src/Cardano/Api/Error.hs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-- | Class of errors used in the Api.
88
module Cardano.Api.Error
99
( Error (..)
10-
, throwErrorAsException
10+
, throwErrorM
1111
, liftEitherError
1212
, failEitherError
1313
, ErrorAsException (..)
@@ -32,24 +32,15 @@ class Error e where
3232
instance 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'.
5546
liftEitherError
@@ -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.
6564
data ErrorAsException where

0 commit comments

Comments
 (0)