better error handling
This commit is contained in:
@@ -184,6 +184,7 @@ class MediaController extends ApiController
|
||||
array_key_exists('mime_type', $data) === true &&
|
||||
$data['mime_type'] !== "") {
|
||||
$error = Media::verifyStorage($data['mime_type'], $data['security']['type'], $data['storage']);
|
||||
// Log::error($data['mime_type'] . ' - ' . $data['security']['type'] . ' - ' . $data['storage']);
|
||||
switch($error) {
|
||||
case Media::STORAGE_VALID:
|
||||
break;
|
||||
@@ -192,7 +193,7 @@ class MediaController extends ApiController
|
||||
case Media::STORAGE_NOT_FOUND:
|
||||
return $this->respondWithErrors(['storage' => 'Storage was not found.']);
|
||||
case Media::STORAGE_INVALID_SECURITY:
|
||||
return $this->respondWithErrors(['storage' => 'Storage invalid for security value.']);
|
||||
return $this->respondWithErrors(['storage' => 'Storage invalid for this security requirement.']);
|
||||
default:
|
||||
return $this->respondWithErrors(['storage' => 'Storage verification error occurred.']);
|
||||
}
|
||||
|
||||
@@ -1020,11 +1020,8 @@ class Media extends Model
|
||||
$storage = 'private';
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if(Storage::disk($storage)->exists('') === false) {
|
||||
return Media::STORAGE_NOT_FOUND;
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
$disks = config('filesystems.disks');
|
||||
if(array_key_exists($storage, $disks) === false) {
|
||||
return Media::STORAGE_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
@@ -1088,14 +1088,17 @@ const uploadFileById = (uploadId: string, file: File): void => {
|
||||
content: `Cannot upload the file ${file.name} as it larger than ${max_upload_size.value}.`,
|
||||
});
|
||||
} else {
|
||||
const message = error.data.message
|
||||
? " " + error.data.message
|
||||
: "";
|
||||
|
||||
useToastStore().addToast({
|
||||
title: "File upload error",
|
||||
type: "danger",
|
||||
content: `Cannot upload the file ${file.name} as a server error occurred.`,
|
||||
content: `Cannot upload the file ${file.name} as a server error occurred.${message}`,
|
||||
});
|
||||
}
|
||||
|
||||
console.log(error);
|
||||
removeMediaItem(uploadId);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user