This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/application/Espo/Utils/Resolver.php
T
2013-11-11 15:35:02 +02:00

58 lines
1.2 KiB
PHP
Executable File

<?php
namespace Espo\Utils;
use Espo\Utils as Utils;
class Resolver extends BaseUtils
{
protected $exceptions = array(
'Doctrine\DBAL\DBALException' => 'DBALException',
'ReflectionException' => 'ReflectionException',
);
public function handle($Exception)
{
$handler= get_class($Exception);
$trace= $Exception->getTrace();
$args= array();
if (is_array($trace[0]['args'])) {
$args= $trace[0]['args'];
}
if (in_array($handler, array_keys($this->exceptions))) {
$method= $this->exceptions[$handler];
$this->getObject('Log')->add('INFO', 'Try to resolve the exception - '.$handler);
$result= false;
try {
$result= $this->$method($args);
} catch(\Exception $e) {
$this->getObject('Log')->add('INFO', 'Could not resolve the exception - '.$handler.'. Details below:');
$this->getObject('Log')->catchException($e, false);
}
return $result;
}
return false;
}
protected function DBALException($args)
{
return $this->getObject('Metadata')->rebuildDatabase();
}
protected function ReflectionException($args)
{
return $this->getObject('Metadata')->generateEntities($args);
}
}
?>