Skip to content

Commit 0e8f507

Browse files
committed
trace-froward: better handle the error cases
1 parent 2a4ad04 commit 0e8f507

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

trace-forward/src/Trace/Forward/Utils/TraceObject.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,14 @@ readFromSink ForwardSink{forwardQueue} =
8282
-- Handle response format outside of `atomically`.
8383
res <- atomically $ readFromSinkSTM forwardQueue blocking n
8484
pure $ case blocking of
85-
TokBlocking -> BlockingReply $ case res of
86-
(x:xs) -> x NE.:| xs
87-
-- If `n == 0` ?????
88-
[] -> error "impossible"
85+
TokBlocking -> BlockingReply $
86+
-- Convert to a non-empty list.
87+
case res of
88+
(x:xs) -> x NE.:| xs
89+
-- Either GHC-impossible or impossible
90+
-- to create a non-empty list with zero
91+
-- items or less.
92+
[] -> error $ "impossible: requested = " ++ show n
8993
TokNonBlocking -> NonBlockingReply res
9094
, Forwarder.recvMsgDone = return ()
9195
}

0 commit comments

Comments
 (0)