I have a given class with some methods in it, one of which throws an exception as per the following when certain faulty criteria is met:
PHP
if ($this->mode !== null) {
throw new LogicException('Nem kezdhető új "insert" utasítás.');
}
If I do not handle this error, PHP will show the "Fatal Error" message as expected, but not the custom message that was passed into the first parameter of the constructor of LogicException
:
Fatal error: in /home/uxxxxxxxxx/public_html/test.php on line 87
I expected that throwing an exception outside of a try ... catch
block would produce the following output in the browser:
Fatal error: Nem kezdhető új "insert" utasítás. in /home/uxxxxxxxxx/public_html/test.php on line 87
If I specify a custom exception handler, it is possible to to display the original message, albeit in a different style. I know how I could mimic the original behaviour of PHP handling catchable fatal errors, but I do think the message should be displayed without requiring that, purely by throwing a non-caught exception.
Note: swapping LogicException
to Exception
doesn't change anything.