Improve error handling for UploadableWidgets
This commit is contained in:
parent
547d9bffeb
commit
434f2cd433
|
|
@ -69,7 +69,12 @@ trait UploadableWidget
|
|||
* See mime type handling in the asset manager
|
||||
*/
|
||||
if (!$uploadedFile->isValid()) {
|
||||
throw new ApplicationException($uploadedFile->getErrorMessage());
|
||||
if ($uploadedFile->getError() === UPLOAD_ERR_OK) {
|
||||
$message = "The file \"{$uploadedFile->getClientOriginalName()}\" uploaded successfully but wasn't available at {$uploadedFile->getPathName()}. Check to make sure that nothing moved it away.";
|
||||
} else {
|
||||
$message = $uploadedFile->getErrorMessage();
|
||||
}
|
||||
throw new ApplicationException($message);
|
||||
}
|
||||
|
||||
// Use the configured upload path unless it's null, in which case use the user-provided path
|
||||
|
|
@ -113,7 +118,7 @@ trait UploadableWidget
|
|||
'result' => 'success'
|
||||
]);
|
||||
} catch (\Exception $ex) {
|
||||
$response = Response::make($ex->getMessage(), 400);
|
||||
throw new ApplicationException($ex->getMessage());
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
|
|
|||
Loading…
Reference in New Issue