From 2e1a3453c4b556e41c5a44c89aa837ad210e61ce Mon Sep 17 00:00:00 2001 From: brenno-duarte Date: Sat, 16 Mar 2024 13:17:09 -0300 Subject: [PATCH] Fixed exception on javascript --- CHANGELOG.md | 9 +++++++++ composer.json | 1 + src/ModernPHPException.php | 2 +- src/Trait/RenderTrait.php | 6 ++++-- tests/UserTest.php | 6 ++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca09cef..c5ca6ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Released Notes +## v3.1.2 - (2024-03-16) + +### Fixed + +- Fixed exception on JavaScript +- Fixed version on `composer.json` + +-------------------------------------------------------------------------- + ## v3.1.1 - (2024-03-11) ### Fixed diff --git a/composer.json b/composer.json index fab7531..7d51f83 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "brenno-duarte/modern-php-exception", "description": "PHP errors in a modern way", "license": "MIT", + "version": "3.1.2", "keywords": [ "exception", "throwable", diff --git a/src/ModernPHPException.php b/src/ModernPHPException.php index 3bf862b..69ce30f 100644 --- a/src/ModernPHPException.php +++ b/src/ModernPHPException.php @@ -15,7 +15,7 @@ class ModernPHPException use HandlerAssetsTrait; use RenderTrait; - public const VERSION = "3.1.0"; + public const VERSION = "3.1.2"; /** * @var Bench diff --git a/src/Trait/RenderTrait.php b/src/Trait/RenderTrait.php index 4caa777..f14b863 100644 --- a/src/Trait/RenderTrait.php +++ b/src/Trait/RenderTrait.php @@ -323,9 +323,11 @@ private function renderSolutionCli(): void public function consoleJS(): void { if ($this->type == "error") { - echo "console.error('[" . $this->getError() . "] " . $this->info_error_exception['message'] . "')" . PHP_EOL; + $message = str_replace(["'", '"'], "", $this->info_error_exception['message']); + echo "console.error('[" . $this->getError() . "] " . $message . "')" . PHP_EOL; } elseif ($this->type == "exception") { - echo "console.error('[" . $this->info_error_exception['type_exception'] . "] " . $this->info_error_exception['message'] . "')" . PHP_EOL; + $message = str_replace(["'", '"'], "", $this->info_error_exception['message']); + echo "console.error('[" . $this->info_error_exception['type_exception'] . "] " . $message . "')" . PHP_EOL; } echo 'var user = { diff --git a/tests/UserTest.php b/tests/UserTest.php index 63a68a7..4283d87 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -22,4 +22,10 @@ public static function staticCall() { throw new CustomException("Error Processing Request"); } + + public function triggerTest() + { + //echo $a; + trigger_error("This is a trigger_error test", E_USER_ERROR); + } }