Skip to content

Commit 0c9707b

Browse files
committed
dmq-node: parsing errors
1 parent ce136ef commit 0c9707b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

dmq-node/src/DMQ/Configuration/Topology.hs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Ouroboros.Network.Diffusion.Topology (NetworkTopology (..))
1717
import Ouroboros.Network.OrphanInstances (localRootPeersGroupsFromJSON,
1818
networkTopologyFromJSON, networkTopologyToJSON)
1919
import Ouroboros.Network.PeerSelection.LedgerPeers.Type (LedgerPeerSnapshot)
20+
import System.Exit (die)
2021

2122
data NoExtraConfig = NoExtraConfig
2223
deriving Show
@@ -55,10 +56,8 @@ readTopologyFile nc = do
5556
handler e = Text.pack $ "DMQ.Topology.readTopologyFile: "
5657
++ displayException e
5758
handlerJSON :: String -> Text
58-
handlerJSON err = mconcat
59-
[ "Is your topology file formatted correctly? "
60-
, "Expecting P2P Topology file format. "
61-
, "The port and valency fields should be numerical. "
59+
handlerJSON err = Text.unlines
60+
[ "topology parsing error:"
6261
, Text.pack err
6362
]
6463

@@ -67,8 +66,7 @@ readTopologyFileOrError
6766
-> IO (NetworkTopology NoExtraConfig NoExtraFlags)
6867
readTopologyFileOrError nc =
6968
readTopologyFile nc
70-
>>= either (\err -> error $ "DMQ.Topology.readTopologyFile: "
71-
<> Text.unpack err)
69+
>>= either (die . Text.unpack)
7270
pure
7371

7472
readPeerSnapshotFile :: FilePath -> IO (Either Text LedgerPeerSnapshot)
@@ -86,14 +84,13 @@ readPeerSnapshotFile psf = do
8684
handler e = Text.pack $ "DMQ.Topology.readLedgerPeerSnapshotFile: "
8785
++ displayException e
8886
handlerJSON :: String -> Text
89-
handlerJSON err = mconcat
90-
[ "Is your snapshot file formatted correctly? "
87+
handlerJSON err = Text.unlines
88+
[ "snapshot file parging error:"
9189
, Text.pack err
9290
]
9391

9492
readPeerSnapshotFileOrError :: FilePath -> IO LedgerPeerSnapshot
9593
readPeerSnapshotFileOrError psf =
9694
readPeerSnapshotFile psf
97-
>>= either (\err -> error $ "DMQ.Topology.readLedgerPeerSnapshotFile: "
98-
<> Text.unpack err)
95+
>>= either (die . Text.unpack)
9996
pure

0 commit comments

Comments
 (0)