IntersectMBO / IntersectMBO/cardano-node
Fix liftToIntegration exception handling and rename
- Dominant language
- Haskell
- Stars
- 3.2k
- Forks
- 754
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 20
Description
## Problem
`liftToIntegration` in `cardano-testnet/src/Testnet/Start/Cardano.hs:104` has two issues:
### 1. Duplicate exception messages
The current exception handler chain:
```haskell
catch @_ @SomeException (runRIO rMap r) (withFrozenCallStack $ failException . toException . stringException . displayException)
```
serializes the exception to a string via `displayException`, then wraps it in a new `StringException` (which captures its own callstack), then passes that to `failException` (which calls `displayException` again). This produces output like:
```
━━━ Exception (StringException) ━━━
UnliftIO.Exception.throwString called with:
! AnnotatedException !
Underlying exception type: StringException
UnliftIO.Exception.throwString called with:
Called from: ...
CallStack (from HasCallStack): ...
Called from: ...
```
The error message and callstack appear twice, and the exception type banners are nested three levels deep.
**Fix:** replace the chain with just `failException`, which already accepts `SomeException`:
```haskell
catch @_ @SomeException (runRIO rMap r) (withFrozenCallStack failException)
```
### 2. Unclear name
`liftToIntegration` doesn't convey what is being lifted from/to. A name like `runRIOInIntegration` would be clearer — it runs a `RIO ResourceMap` action inside Hedgehog's `Integration` monad.
## Context
Originally flagged as tech debt from https://github.com/IntersectMBO/cardano-node/pull/6346 (unresolved comments by @carbolymer), revisited in https://github.com/IntersectMBO/cardano-node/pull/6559#discussion_r3200025726.
Contributor guide
Assessment
This issue has not been assessed yet.