Skip to content

Commit

Permalink
log: reorganize Show ValidationFailure error message
Browse files Browse the repository at this point in the history
Lead with description, follow with header, add parent and adjacents 
only if relevant and available.

Change-Id: Iba0c7994480e9e958b61529c7d521241a5867bd9
  • Loading branch information
edmundnoble committed May 31, 2024
1 parent 24ff3ca commit 3ab3e64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/2024-05-30T145855-0400.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reorganize ValidationFailure error message to be more readable
6 changes: 3 additions & 3 deletions src/Chainweb/BlockHeader/Validation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ webStepFailure hp = ValidationFailure
instance Show ValidationFailure where
show (ValidationFailure p as e ts)
= T.unpack $ "Validation failure"
<> ". Parent: " <> encodeToText (ObjectEncoded . _parentHeader <$> p)
<> ". Adjacents: " <> encodeToText ((fmap (ObjectEncoded . _parentHeader)) <$> as)
<> ". Header: " <> encodeToText (ObjectEncoded e)
<> ". Description: " <> T.unlines (map description ts)
<> ". Header: " <> encodeToText (ObjectEncoded e)
<> maybe "" (\p' -> ". Parent: " <> encodeToText (ObjectEncoded $ _parentHeader p')) p
<> maybe "" (\as' -> ". Adjacents: " <> encodeToText (ObjectEncoded . _parentHeader <$> as')) as
where
description t = case t of
MissingParent -> "Parent isn't in the database"
Expand Down

0 comments on commit 3ab3e64

Please sign in to comment.