Refactor IStorage

This commit is contained in:
Philipp 2021-08-01 14:00:48 +02:00
parent 5dcdf2322e
commit 29c7552df5
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
11 changed files with 121 additions and 55 deletions

View file

@ -52,12 +52,12 @@ class ExternalResource implements IStorage
try {
$fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, ['accept_content' => '']);
} catch (Exception $exception) {
throw new StorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
}
if ($fetchResult->isSuccess()) {
return $fetchResult->getBody();
} else {
throw new StorageException(sprintf('External resource failed to get %s', $reference), $fetchResult->getReturnCode(), new Exception($fetchResult->getBody()));
throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $fetchResult->getReturnCode(), new Exception($fetchResult->getBody()));
}
}

View file

@ -131,6 +131,8 @@ class Filesystem implements ISelectableStorage
if ($result === false) {
throw new StorageException(sprintf('Filesystem storage failed to get data to "%s". Check your write permissions', $file));
}
return $result;
}
/**