Skip to content
Advertisement

PHP: Append to thrown exception message

Take the following function as an example of what I want to do:

JavaScript

I have nested try() and catch() statements. An exception is thrown from the inner-most and is caught, I then perform some functions and throw another exception. Notice where I write $e .=, I understand this is the incorrect syntax. What I want to do is append the string to the exception’s $e->getMessage().

How would I go about doing this?

Advertisement

Answer

Create you own exception class and create method for appending string to the message.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement