Skip to content
Permalink
Browse files

change error message for fatal errors in PHP 7

  • Loading branch information...
thinkingmedia
thinkingmedia committed Jul 19, 2016
1 parent 2fd23df commit 2d68a046a0c3cf2b38097927d6617a1260687c87
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/View/Cell.php
@@ -25,6 +25,7 @@
use Cake\Utility\Inflector;
use Cake\View\Exception\MissingCellViewException;
use Cake\View\Exception\MissingTemplateException;
use Error;
use Exception;
use ReflectionException;
use ReflectionMethod;
@@ -257,17 +258,18 @@ protected function _cacheConfig($action)
*
* *Note* This method will trigger an error when view rendering has a problem.
* This is because PHP will not allow a __toString() method to throw an exception.
*
* @return string Rendered cell
* @throws Error Include error details for PHP 7 fatal errors.
*/
public function __toString()
{
try {
return $this->render();
} catch (Exception $e) {
trigger_error(sprintf('Could not render cell - %s [%s, line %d]', $e->getMessage(), $e->getFile(), $e->getLine()), E_USER_WARNING);
return '';
} catch(Error $e) {
throw new Error(sprintf('Could not render cell - %s [%s, line %d]', $e->getMessage(), $e->getFile(), $e->getLine()));
}
}

0 comments on commit 2d68a04

Please sign in to comment.
You can’t perform that action at this time.