Skip to content

Commit 7853b82

Browse files
committed
Tracked to appendFile
Display exception aswell
1 parent ec5d0bc commit 7853b82

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cardano-testnet/src/Testnet/Runtime.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Testnet.Types (TestnetNode (..), TestnetRuntime (configurationF
6060
import Hedgehog.Extras.Stock.IO.Network.Sprocket (Sprocket (..))
6161
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as H
6262
import qualified Hedgehog.Extras.Test.Concurrent as H
63+
import RIO.Directory (doesFileExist)
6364

6465
data NodeStartFailure
6566
= ProcessRelatedFailure ProcessError
@@ -343,8 +344,13 @@ startLedgerNewEpochStateLogging testnetRuntime tmpWorkspace = withFrozenCallStac
343344
-- | Handle all sync exceptions and log them into the log file. We don't want to fail the test just
344345
-- because logging has failed.
345346
handleException = handle $ \(e :: SomeException) -> do
346-
liftIOAnnotated $ appendFile outputFp $ "Ledger new epoch logging failed - caught exception:\n"
347-
<> displayException e <> "\n"
347+
exists <- doesFileExist outputFp
348+
if exists
349+
then liftIOAnnotated $ appendFile outputFp $ "Ledger new epoch logging failed - caught exception:\n"
350+
<> displayException e <> "\n"
351+
else do
352+
353+
error $ unlines ["File does not exist: " <> outputFp, "Exception caught during logging:", displayException e]
348354
pure ConditionMet
349355

350356
calculateEpochStateDiff

0 commit comments

Comments
 (0)