From bdd42efb96cce606b56a065c6ff8fef643f0819e Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 22 Aug 2023 07:35:18 +0300 Subject: [PATCH 1/2] Improved 400 error messages --- src/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.php b/src/App.php index f81c352c..300f1b01 100755 --- a/src/App.php +++ b/src/App.php @@ -739,7 +739,7 @@ protected function validate(string $key, array $param, mixed $value): void } if (!$validator->isValid($value)) { - throw new Exception('Invalid ' . $key . ': ' . $validator->getDescription(), 400); + throw new Exception('Invalid `' . $key . '` param: ' . $validator->getDescription(), 400); } } From 9bd15dfce16fd469841251449898775537203a90 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 22 Aug 2023 08:12:53 +0300 Subject: [PATCH 2/2] Fixed test --- tests/AppTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AppTest.php b/tests/AppTest.php index 5f08054a..d3952185 100755 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -185,7 +185,7 @@ public function testCanExecuteRoute(): void $result = \ob_get_contents(); \ob_end_clean(); - $this->assertEquals('error: Invalid x: Value must be a valid string and no longer than 1 chars', $result); + $this->assertEquals('error: Invalid `x` param: Value must be a valid string and no longer than 1 chars', $result); // With Hooks