Search code examples
phpexceptionzend-framework2php-7error-reporting

ZF2 2.5 not always showing full error message


Since I updated Zend-Framework to version 2.5.3 and PHP to version 7.0, I don't always get the full error message if an exception occurs.

e.g.: an exception occured and the only way I can get the exception message is by using the debugger (Class: ExceptionStrategy, Row: 121):

enter image description here

In the frontend, only a generic error message is displayed:

enter image description here I have turned on the PHP error reporting (in my local.php and php.ini):

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

Oddly enough, sometimes I get the full error message including the stack-trace and everything I need for debugging, but sometimes I only get just that generic error message.

I would expect it to look like this:

enter image description here

Has someone experienced that behavior? Is that normal?


Solution

  • Ok now I found it. The problem was in my error template because there is an if-statement which checks if the exception is an instance of Exception:

    <?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
    

    Since PHP 7 most errors are reported with error exception, so I had to extend the if-statement like this:

    <?php if(isset($this->exception) && ($this->exception instanceof Exception || $this->exception instanceof Error)): ?>