fixed FieldManager bug, when rebuild exception

This commit is contained in:
Taras Machyshyn
2014-06-02 17:19:09 +03:00
parent defa3b5cfc
commit 60b11cb11e
2 changed files with 9 additions and 3 deletions

View File

@@ -55,7 +55,12 @@ class FieldManager extends \Espo\Core\Controllers\Base
$fieldManager = $this->getContainer()->get('fieldManager');
$fieldManager->create($data['name'], $data, $params['scope']);
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
try {
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
} catch (Error $e) {
$fieldManager->delete($data['name'], $params['scope']);
throw new Error($e->getMessage());
}
return $fieldManager->read($data['name'], $params['scope']);
}

View File

@@ -22,7 +22,8 @@
namespace Espo\Core\Utils;
use \Espo\Core\Exceptions\Error;
use \Espo\Core\Exceptions\Error,
\Espo\Core\Exceptions\Conflict;
class FieldManager
{
@@ -74,7 +75,7 @@ class FieldManager
{
$existingField = $this->getFieldDef($name, $scope);
if (isset($existingField)) {
throw new Error('Field ['.$name.'] exists in '.$scope);
throw new Conflict('Field ['.$name.'] exists in '.$scope);
}
return $this->update($name, $fieldDef, $scope);