I have a file download mechanism with axios and laravel. From the side of php I have several situations where I have to throw exceptions.
for example
$result = file_put_contents($filepath, $filedata);
if($result){
$photoModer = new PhotoModeration();
$photoModer->newUserUpload($filepath);
return true;
}else{
throw new Exceptions\FileUploadException('Can not upload file');
}
In my controller I pass the data to the side js with json array
if($resultUpload === true){
$json_array = [
'status' => 'success',
'message' => 'Success'
];
}else{
$json_array = [
'status' => 'error',
'message' => 'Error'
];
}
return json_encode($json_array);
then in js I just use result.text
. My question is in the following.
Is it possible, in any way, to pass the text from exception to the side js?