UploadException.php in Plupload integration 2.0.x
File
src/UploadException.php
View source
<?php
namespace Drupal\plupload;
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;
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.',
self::FILENAME_ERROR => 'Invalid temporary file name.',
];
public function __construct($code) {
$this->code = $code;
$this->message = $this->errorMessages[$this->code];
}
public function getErrorResponse() {
return new JsonResponse([
'jsonrpc' => '2.0',
'error' => [
'code' => $this->code,
'message' => $this->errorMessages[$this->code],
],
'id' => 'id',
], 500);
}
}