For example using the PHP service sdk:
try {
$s3Client->createBucket(array(
'Bucket' => 'my-bucket'
));
} catch (\Aws\S3\Exception\S3Exception $e) {
// The AWS error code (e.g., )
echo $e->getAwsErrorCode() . "\n";
// The bucket couldn't be created
echo $e->getMessage() . "\n";
}
Note I have to use \Aws\S3\Exception\S3Exception
I have tried using the catch with AmazonServiceException and AwsException but neither of them catch the error I force. I can just do catch( exception $e) but then the functions getMessage etc don't work.
Aucun commentaire:
Enregistrer un commentaire