1
0
Fork 0
mirror of synced 2024-06-26 10:10:57 +12:00

feat: update error codes in the storage API

This commit is contained in:
Christy Jacob 2022-02-06 18:40:22 +04:00
parent d9fbe80317
commit 4905792bb5
3 changed files with 8 additions and 2 deletions

View file

@ -241,7 +241,12 @@ return [
],
Exception::STORAGE_FAILED_TO_MOVE_FILE => [
'name' => Exception::STORAGE_FAILED_TO_MOVE_FILE,
'description' => 'Failed to copy the uploaded file.',
'description' => 'Failed to move the uploaded file.',
'statusCode' => 500,
],
Exception::STORAGE_FAILED_TO_WRITE_FILE => [
'name' => Exception::STORAGE_FAILED_TO_WRITE_FILE,
'description' => 'Failed to save the uploaded file.',
'statusCode' => 500,
],
];

View file

@ -141,7 +141,7 @@ App::post('/v1/storage/files')
$data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag);
if (!$device->write($path, $data, $mimeType)) {
throw new Exception('Failed to save file', 500);
throw new Exception('Failed to save file', 500, Exception::STORAGE_FAILED_TO_WRITE_FILE);
}
$sizeActual = $device->getFileSize($path);

View file

@ -68,6 +68,7 @@ class Exception extends \Exception
const STORAGE_INVALID_FILE_SIZE = 'storage_invalid_file_size';
const STORAGE_INVALID_FILE = 'storage_invalid_file';
const STORAGE_FAILED_TO_MOVE_FILE = 'storage_failed_to_move_file';
const STORAGE_FAILED_TO_WRITE_FILE = 'storage_failed_to_write_file';
/** Projects */
const PROJECT_NOT_FOUND = 'project_not_found';