From aa61adc5e983060aa3233df4004ee3db2575ed4d Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 26 Jan 2023 22:36:42 +0100 Subject: [PATCH] Improverbosity by InvalidBody showing the root and the reason. --- src/PSR7/Exception/Validation/InvalidBody.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PSR7/Exception/Validation/InvalidBody.php b/src/PSR7/Exception/Validation/InvalidBody.php index 1cdd6f15..4f1743b0 100644 --- a/src/PSR7/Exception/Validation/InvalidBody.php +++ b/src/PSR7/Exception/Validation/InvalidBody.php @@ -17,7 +17,12 @@ public static function becauseBodyDoesNotMatchSchema( SchemaMismatch $prev ): self { $exception = static::fromAddrAndPrev($addr, $prev); - $exception->message = sprintf('Body does not match schema for content-type "%s" for %s', $contentType, $addr); + $exception->message = sprintf( + 'Body does not match schema for content-type "%s" for %s. [%s in %s]', + $contentType, + $addr, + substr($prev->getMessage(), 0, -1), + implode('->', $prev->dataBreadCrumb()->buildChain())); return $exception; }