Skip to content

Fix liftToIntegration exception handling and rename #6567

@palas

Description

@palas

Problem

liftToIntegration in cardano-testnet/src/Testnet/Start/Cardano.hs:104 has two issues:

1. Duplicate exception messages

The current exception handler chain:

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:

<actual error message>
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:

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 #6346 (unresolved comments by @carbolymer), revisited in #6559 (comment).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions