Sepultura
Sepultura

Reputation: 1047

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?

Upvotes: 0

Views: 350

Answers (2)

Sepultura
Sepultura

Reputation: 1047

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)): ?>

Upvotes: 2

Wilt
Wilt

Reputation: 44422

Not sure if this is causing your problems but worth mentioning it anyway.

You have to configure your view-manager to display/render exceptions. You can read more on how to configure your view renderer inside the ZF2 documentation here.

There is a dedicated key inside the view manager config:

'display_exceptions' => true,

Upvotes: 0

Related Questions