public function initErrorHandler(Error\ErrorHandlerInterface $errorHandler)
{
$this->getDI()->getEventsManager()->attach('dispatch:beforeException', function ($event, $dispatcher, $exception) {
//For fixing phalcon weird behavior https://github.com/phalcon/cphalcon/issues/2558
throw $exception;
});
if ($this->getDI()->getConfig()->debug && $this->appMode != 'cli') {
return $this;
}
$errorClass = get_class($errorHandler);
set_error_handler("{$errorClass}::errorHandler");
set_exception_handler("{$errorClass}::exceptionHandler");
register_shutdown_function("{$errorClass}::shutdownHandler");
return $this;
}