Skip to content

Commit

Permalink
update filesystem to consider adapters exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasmure committed Sep 22, 2017
1 parent 973388e commit 1eb1a05
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Gaufrette/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Gaufrette;

use Gaufrette\Adapter\ListKeysAware;
use Gaufrette\Exception as GaufretteException;

/**
* A filesystem is used to store and retrieve files.
Expand Down Expand Up @@ -63,7 +64,9 @@ public function rename($sourceKey, $targetKey)
throw new Exception\UnexpectedFile($targetKey);
}

if (!$this->adapter->rename($sourceKey, $targetKey)) {
try {
$this->adapter->rename($sourceKey, $targetKey);
} catch (GaufretteException $e) {
throw new \RuntimeException(sprintf('Could not rename the "%s" key to "%s".', $sourceKey, $targetKey));
}

Expand Down Expand Up @@ -136,13 +139,14 @@ public function delete($key)

$this->assertHasFile($key);

if ($this->adapter->delete($key)) {
try {
$this->adapter->delete($key);
$this->removeFromRegister($key);

return true;
} catch (GaufretteException $e) {
throw new \RuntimeException(sprintf('Could not remove the "%s" key.', $key));
}

throw new \RuntimeException(sprintf('Could not remove the "%s" key.', $key));
}

/**
Expand Down

0 comments on commit 1eb1a05

Please sign in to comment.