diff --git a/src/Gaufrette/Filesystem.php b/src/Gaufrette/Filesystem.php index 04860f573..d4a9059f6 100644 --- a/src/Gaufrette/Filesystem.php +++ b/src/Gaufrette/Filesystem.php @@ -3,6 +3,7 @@ namespace Gaufrette; use Gaufrette\Adapter\ListKeysAware; +use Gaufrette\Exception as GaufretteException; /** * A filesystem is used to store and retrieve files. @@ -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)); } @@ -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)); } /**