diff --git a/changes/2024-05-30T145855-0400.txt b/changes/2024-05-30T145855-0400.txt new file mode 100644 index 0000000000..a49ea0e177 --- /dev/null +++ b/changes/2024-05-30T145855-0400.txt @@ -0,0 +1 @@ +Reorganize ValidationFailure error message to be more readable diff --git a/src/Chainweb/BlockHeader/Validation.hs b/src/Chainweb/BlockHeader/Validation.hs index 7bd425c9ee..87c4ebfc2a 100644 --- a/src/Chainweb/BlockHeader/Validation.hs +++ b/src/Chainweb/BlockHeader/Validation.hs @@ -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"