unclecheese/silverstripe-dropzone

Proper Handling of Validation messages

Opened this issue · 0 comments

FileAttachmentField.php should show the validation exception message provided with something like the following.

try {
    $this->upload->loadIntoFile($tmpFile, $fileObject, $this->getFolderName());
    $ids[] = $fileObject->ID;
} catch (ValidationException $e) {
  return $this->httpError(400, $e->getMessage());
} catch (Exception $e) {
  $error_message = _t('FileAttachmentField.GENERALUPLOADERROR', 'Sorry, the file could not be saved at the current time, please try again later.');
  return $this->httpError(400, $error_message);
}