UploadException.php in DropzoneJS 8.2
File
src/UploadException.php
View source
<?php
namespace Drupal\dropzonejs;
use Symfony\Component\HttpFoundation\JsonResponse;
class UploadException extends \Exception {
const INPUT_ERROR = 101;
const OUTPUT_ERROR = 102;
const MOVE_ERROR = 103;
const DESTINATION_FOLDER_ERROR = 104;
const FILENAME_ERROR = 105;
const FILE_UPLOAD_ERROR = 106;
public $errorMessages = [
self::INPUT_ERROR => 'Failed to open input stream.',
self::OUTPUT_ERROR => 'Failed to open output stream.',
self::MOVE_ERROR => 'Failed to move uploaded file.',
self::DESTINATION_FOLDER_ERROR => 'Failed to open temporary directory for write.',
self::FILENAME_ERROR => 'Invalid temporary file name.',
self::FILE_UPLOAD_ERROR => 'The file upload resulted in an error on php level. See http://php.net/manual/en/features.file-upload.errors.php',
];
public function __construct($code, $message = NULL) {
$this->code = $code;
$this->message = isset($message) ? $message : $this->errorMessages[$this->code];
}
public function getErrorResponse() {
return new JsonResponse([
'jsonrpc' => '2.0',
'error' => $this->errorMessages[$this->code],
'id' => 'id',
], 500);
}
}