MDL-48889 repository_s3: pipe S3Exception messages into moodle

When processing S3Exceptions thrown by the S3 library, pass
the exception messages into the moodle_exceptions being
created in order to actually tell people what went wrong.
This commit is contained in:
Jetha Chan 2015-01-29 17:41:32 +08:00
parent e0ae3519a1
commit 20a263ecfa

View File

@ -101,7 +101,13 @@ class repository_s3 extends repository {
try {
$buckets = $this->s->listBuckets();
} catch (S3Exception $e) {
throw new moodle_exception('errorwhilecommunicatingwith', 'repository', '', $this->get_name());
throw new moodle_exception(
'errorwhilecommunicatingwith',
'repository',
'',
$this->get_name(),
$e->getMessage()
);
}
foreach ($buckets as $bucket) {
$folder = array(
@ -120,7 +126,13 @@ class repository_s3 extends repository {
try {
$contents = $this->s->getBucket($bucket, $uri, null, null, '/', true);
} catch (S3Exception $e) {
throw new moodle_exception('errorwhilecommunicatingwith', 'repository', '', $this->get_name());
throw new moodle_exception(
'errorwhilecommunicatingwith',
'repository',
'',
$this->get_name(),
$e->getMessage()
);
}
foreach ($contents as $object) {
@ -195,7 +207,13 @@ class repository_s3 extends repository {
try {
$this->s->getObject($bucket, $uri, $path);
} catch (S3Exception $e) {
throw new moodle_exception('errorwhilecommunicatingwith', 'repository', '', $this->get_name());
throw new moodle_exception(
'errorwhilecommunicatingwith',
'repository',
'',
$this->get_name(),
$e->getMessage()
);
}
return array('path' => $path);
}