From 48e5d333dc13e8f2aa8f9e28280a8eb27d7a8453 Mon Sep 17 00:00:00 2001 From: Edmund Noble Date: Sat, 25 May 2024 14:29:39 -0400 Subject: [PATCH] log: reorganize Show ValidationFailure error message Lead with description, follow with header, add parent and adjacents only if relevant and available. Change-Id: Iba0c7994480e9e958b61529c7d521241a5867bd9 --- changes/2024-05-30T145855-0400.txt | 1 + src/Chainweb/BlockHeader/Validation.hs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changes/2024-05-30T145855-0400.txt 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"