Add a way to clarify custom cleveland errors
Clarification and motivation
I once tried to write the following function in a side-project, but miserably failed:
-- | Prefix /scenario-custom/ errors messages potentially coming from the given
-- code block.
--
-- The prefix will be put at a separate line before the main text.
--
-- This affects errors produced by functions like @failure@, @assert@, @\@==@.
-- Errors related to events in the chain will not be touched.
--
-- >>> for [1..10] \i -> 'clarifyErrors' ("For i=" +| i |+ "") $
-- >>> askContract i @@== i * 2
clarifyErrors :: (MonadNettest caps base m, MonadThrow m) => Builder -> m a -> m a
However defining it as part of Cleveland framework must be way simpler and more robust, so would be nice to see it there.
(The main issue here is that we have to handle 4 different errors - one from Client implementation, one from Pure, and those two also each have a variation when being wrapped into WithCallStack
).
The output that should be produced by the example mentioned in the haddock:
| For i=1
| Failed comparison
| ━━ Expected (rhs) ━━
| 1
| ━━ Got (lhs) ━━
| 2
Acceptance criteria
- The function with behaviour mentioned above is exposed by the Cleveland interface.
Edited by Konstantin Ivanov