Cannot catch AWS S3 exception

Ok so here is what worked for me:

use Aws\S3\Exception\S3Exception as S3;


try {
    $podcast = $this->uploadFileToS3($request);
} catch(S3 $e) {
    return $e->getMessage();
 }

In my case, i passed the message to a session flash like so:

 return redirect('dashboard/episode/create')->with('status', $e->getMessage());

So it all depends on how you want to use it.

try {
    $fileSize = filesize("s3://".$bucket."/".$filename);
} catch(S3 $e) {
    return $e->getMessage();
 }

Good Luck!


This is the right way.

use Aws\Exception\AwsException;

try{
    // something
}catch(AwsException $e){
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}