Merge pull request #348 from mailpoet/page_reviews

Page reviews
This commit is contained in:
mrcasual
2016-02-12 13:36:47 -05:00
12 changed files with 139 additions and 68 deletions

View File

@@ -41,7 +41,24 @@ class Model extends \Sudzy\ValidModel {
} catch(\Sudzy\ValidationException $e) {
$this->setError($e->getValidationErrors());
} catch(\PDOException $e) {
$this->setError($e->getMessage());
switch($e->getCode()) {
case 23000:
preg_match("/for key \'(.*?)\'/i", $e->getMessage(), $matches);
if(isset($matches[1])) {
$column = $matches[1];
$this->setError(
sprintf(
__('Another record already exists. Please specify a different "%1$s".'),
$column
)
);
} else {
$this->setError($e->getMessage());
}
break;
default:
$this->setError($e->getMessage());
}
} catch(\Exception $e) {
$this->setError($e->getMessage());
}