Created
May 17, 2024 00:37
-
-
Save aklump/b997135e03771a5ac26d61a09d409fe6 to your computer and use it in GitHub Desktop.
How to alter an Exception message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$augmented_message = $exception->getMessage() . "\nMy augementation"; | |
$reflected_exception = new \ReflectionObject($exception); | |
$message_property = $reflected_exception->getProperty('message'); | |
$message_property->setAccessible(TRUE); | |
$message_property->setValue($exception, $augmented_message); | |
throw $exception; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment