mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #5117 from tractorcow/pulls/4.0/soft-errors
BUG Prevent fatal errors during test failure halt tests
This commit is contained in:
commit
08c6aca9a4
@ -5,6 +5,7 @@ namespace SilverStripe\Filesystem\Flysystem;
|
||||
use Config;
|
||||
use Generator;
|
||||
use Injector;
|
||||
use LogicException;
|
||||
use Session;
|
||||
use Flushable;
|
||||
use InvalidArgumentException;
|
||||
@ -98,7 +99,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
*/
|
||||
public function setPublicFilesystem(Filesystem $filesystem) {
|
||||
if(!$filesystem->getAdapter() instanceof PublicAdapter) {
|
||||
throw new \InvalidArgumentException("Configured adapter must implement PublicAdapter");
|
||||
throw new InvalidArgumentException("Configured adapter must implement PublicAdapter");
|
||||
}
|
||||
$this->publicFilesystem = $filesystem;
|
||||
return $this;
|
||||
@ -108,8 +109,12 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
* Get the currently assigned flysystem backend
|
||||
*
|
||||
* @return Filesystem
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function getPublicFilesystem() {
|
||||
if(!$this->publicFilesystem) {
|
||||
throw new LogicException("Filesystem misconfiguration error");
|
||||
}
|
||||
return $this->publicFilesystem;
|
||||
}
|
||||
|
||||
@ -121,7 +126,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
*/
|
||||
public function setProtectedFilesystem(Filesystem $filesystem) {
|
||||
if(!$filesystem->getAdapter() instanceof ProtectedAdapter) {
|
||||
throw new \InvalidArgumentException("Configured adapter must implement ProtectedAdapter");
|
||||
throw new InvalidArgumentException("Configured adapter must implement ProtectedAdapter");
|
||||
}
|
||||
$this->protectedFilesystem = $filesystem;
|
||||
return $this;
|
||||
@ -133,6 +138,9 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
* @return Filesystem
|
||||
*/
|
||||
public function getProtectedFilesystem() {
|
||||
if(!$this->protectedFilesystem) {
|
||||
throw new Exception("Filesystem misconfiguration error");
|
||||
}
|
||||
return $this->protectedFilesystem;
|
||||
}
|
||||
|
||||
@ -624,7 +632,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
switch($conflictResolution) {
|
||||
// Throw tantrum
|
||||
case static::CONFLICT_EXCEPTION: {
|
||||
throw new \InvalidArgumentException("File already exists at path {$fileID}");
|
||||
throw new InvalidArgumentException("File already exists at path {$fileID}");
|
||||
}
|
||||
|
||||
// Rename
|
||||
@ -635,7 +643,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("File could not be renamed with path {$fileID}");
|
||||
throw new InvalidArgumentException("File could not be renamed with path {$fileID}");
|
||||
}
|
||||
|
||||
// Use existing file
|
||||
|
@ -38,6 +38,9 @@ class FlysystemGeneratedAssetHandler implements GeneratedAssetHandler {
|
||||
* @return Filesystem
|
||||
*/
|
||||
public function getFilesystem() {
|
||||
if(!$this->assetStore) {
|
||||
throw new Exception("Filesystem misconfiguration error");
|
||||
}
|
||||
return $this->assetStore;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user