I recently migrated from age old amazon AWS SDK (v1.6.2) for PHP to the latest one. One thing I completely missed was Exception handling.
My first code.
$result = $this->S3Client->putObject($options);
if (!empty($result)) {
return !0;
}
But if upload fails, then it will throw an exception which will crash my PHP. So, I added exception handling next.
try {
$result = $this->S3Client->putObject($options);
return !0;
} catch(Exception $e) {
log_message($e->message);
return !1;
}
However, it seems that $e->message
is protected.
Question: How can I get the error so that I can root cause what happened with the upload, once I move to production environment?