Fixes vague error when attribute is not fillable

Previously an error was being thrown with just the attribute name, not helpful at all.
Fixes #2302
This commit is contained in:
Samuel Georges 2016-08-13 10:48:52 +10:00
parent 6070d2f6bd
commit d7b9b4f65e

View File

@ -8,6 +8,7 @@ use Backend;
use BackendAuth;
use Backend\Classes\ControllerBehavior;
use Backend\Behaviors\ImportExportController\TranscodeFilter;
use Illuminate\Database\Eloquent\MassAssignmentException;
use League\Csv\Reader as CsvReader;
use League\Csv\Writer as CsvWriter;
use ApplicationException;
@ -189,6 +190,12 @@ class ImportExportController extends ControllerBehavior
$this->vars['importResults'] = $model->getResultStats();
$this->vars['returnUrl'] = $this->getRedirectUrlForType('import');
}
catch (MassAssignmentException $ex) {
$this->controller->handleError(new ApplicationException(Lang::get(
'backend::lang.model.mass_assignment_failed',
['attribute' => $ex->getMessage()]
)));
}
catch (Exception $ex) {
$this->controller->handleError($ex);
}
@ -411,6 +418,12 @@ class ImportExportController extends ControllerBehavior
$this->vars['fileUrl'] = $fileUrl;
$this->vars['returnUrl'] = $this->getRedirectUrlForType('export');
}
catch (MassAssignmentException $ex) {
$this->controller->handleError(new ApplicationException(Lang::get(
'backend::lang.model.mass_assignment_failed',
['attribute' => $ex->getMessage()]
)));
}
catch (Exception $ex) {
$this->controller->handleError($ex);
}