Skip to content

Commit

Permalink
chore: More detailed isolationUnderParse error
Browse files Browse the repository at this point in the history
  • Loading branch information
414owen committed Jul 24, 2024
1 parent 81c393a commit c97df67
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Data/Serialize/Get.hs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ negativeIsolation :: Get a
negativeIsolation = fail "Attempted to isolate a negative number of bytes"

isolationUnderParse :: Get a
isolationUnderParse = fail "Isolated parser didn't consume all input"
isolationUnderParse = fail "Isolated parser didn't consume all input"

isolationUnderSupply :: Get a
isolationUnderSupply = fail "Too few bytes supplied to isolated parser"
Expand Down Expand Up @@ -467,7 +467,11 @@ isolateLazy n parser = do
failRaw msg stack
Done a bs -> do
bytesRead' <- bytesRead
unless (bytesRead' - initialBytesRead == n && B.null bs) isolationUnderParse
unless (bytesRead' - initialBytesRead == n && B.null bs)
$ fail $ "Isolated parser didn't consume all input. "
<> "Internal leftovers: " <> show bs
<> ", bytesRead: " <> show (bytesRead' - initialBytesRead)
<> ", isolation amt: " <> show n
pure a
Partial cont -> do
pos <- bytesRead
Expand Down

0 comments on commit c97df67

Please sign in to comment.