Skip to content

Commit

Permalink
Remove FileTaskException
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jan 28, 2016
1 parent eca3b08 commit dda11ea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 36 deletions.
34 changes: 17 additions & 17 deletions src/Concurrent/ConcurrentDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Icicle\Concurrent\Worker;
use Icicle\Concurrent\Worker\Pool;
use Icicle\File\Driver;
use Icicle\File\Exception\FileTaskException;
use Icicle\File\Exception\FileException;

class ConcurrentDriver implements Driver
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public function open($path, $mode)
try {
list($id, $size, $append) = (yield $worker->enqueue($task));
} catch (TaskException $exception) {
throw new FileTaskException('Opening the file failed.', $exception);
throw new FileException('Opening the file failed.', $exception);
}

yield new ConcurrentFile($worker, $id, $path, $size, $append);
Expand All @@ -51,7 +51,7 @@ public function unlink($path)
try {
yield $this->pool->enqueue(new Internal\FileTask('unlink', [(string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Unlinking the file failed.', $exception);
throw new FileException('Unlinking the file failed.', $exception);
}
}

Expand All @@ -63,7 +63,7 @@ public function stat($path)
try {
yield $this->pool->enqueue(new Internal\FileTask('stat', [(string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Stating the file failed.', $exception);
throw new FileException('Stating the file failed.', $exception);
}
}

Expand All @@ -75,7 +75,7 @@ public function rename($oldPath, $newPath)
try {
yield $this->pool->enqueue(new Internal\FileTask('rename', [(string) $oldPath, (string) $newPath]));
} catch (TaskException $exception) {
throw new FileTaskException('Renaming the file failed.', $exception);
throw new FileException('Renaming the file failed.', $exception);
}
}

Expand All @@ -87,7 +87,7 @@ public function isFile($path)
try {
yield $this->pool->enqueue(new Internal\FileTask('isfile', [(string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Determining if path is a file failed.', $exception);
throw new FileException('Determining if path is a file failed.', $exception);
}
}

Expand All @@ -99,7 +99,7 @@ public function isDir($path)
try {
yield $this->pool->enqueue(new Internal\FileTask('isdir', [(string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Determine if the path is a directory failed.', $exception);
throw new FileException('Determine if the path is a directory failed.', $exception);
}
}

Expand All @@ -111,7 +111,7 @@ public function link($source, $target)
try {
yield $this->pool->enqueue(new Internal\FileTask('link', [(string) $source, (string) $target]));
} catch (TaskException $exception) {
throw new FileTaskException('Creating the link failed.', $exception);
throw new FileException('Creating the link failed.', $exception);
}
}

Expand All @@ -123,7 +123,7 @@ public function symlink($source, $target)
try {
yield $this->pool->enqueue(new Internal\FileTask('symlink', [(string) $source, (string) $target]));
} catch (TaskException $exception) {
throw new FileTaskException('Creating the symlink failed.', $exception);
throw new FileException('Creating the symlink failed.', $exception);
}
}

Expand All @@ -135,7 +135,7 @@ public function readlink($path)
try {
yield $this->pool->enqueue(new Internal\FileTask('readlink', [(string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Reading the symlink failed.', $exception);
throw new FileException('Reading the symlink failed.', $exception);
}
}

Expand All @@ -147,7 +147,7 @@ public function copy($source, $target)
try {
yield $this->pool->enqueue(new Internal\FileTask('copy', [(string) $source, (string) $target]));
} catch (TaskException $exception) {
throw new FileTaskException('Copying the file failed.', $exception);
throw new FileException('Copying the file failed.', $exception);
}
}

Expand All @@ -159,7 +159,7 @@ public function mkDir($path, $mode = 0755)
try {
yield $this->pool->enqueue(new Internal\FileTask('mkdir', [(string) $path, (int) $mode]));
} catch (TaskException $exception) {
throw new FileTaskException('Creating the directory failed.', $exception);
throw new FileException('Creating the directory failed.', $exception);
}
}

Expand All @@ -171,7 +171,7 @@ public function lsDir($path)
try {
yield $this->pool->enqueue(new Internal\FileTask('lsdir', [(string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Reading the directory failed.', $exception);
throw new FileException('Reading the directory failed.', $exception);
}
}

Expand All @@ -183,7 +183,7 @@ public function rmDir($path)
try {
yield $this->pool->enqueue(new Internal\FileTask('rmdir', [(string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Reading the directory failed.', $exception);
throw new FileException('Reading the directory failed.', $exception);
}
}

Expand All @@ -195,7 +195,7 @@ public function chmod($path, $mode)
try {
yield $this->pool->enqueue(new Internal\FileTask('chmod', [(string) $path, (int) $mode]));
} catch (TaskException $exception) {
throw new FileTaskException('Creating the directory failed.', $exception);
throw new FileException('Creating the directory failed.', $exception);
}
}

Expand All @@ -207,7 +207,7 @@ public function chown($path, $uid)
try {
yield $this->pool->enqueue(new Internal\FileTask('chown', [(string) $path, (int) $uid]));
} catch (TaskException $exception) {
throw new FileTaskException('Creating the directory failed.', $exception);
throw new FileException('Creating the directory failed.', $exception);
}
}

Expand All @@ -219,7 +219,7 @@ public function chgrp($path, $gid)
try {
yield $this->pool->enqueue(new Internal\FileTask('chgrp', [(string) $path, (int) $gid]));
} catch (TaskException $exception) {
throw new FileTaskException('Creating the directory failed.', $exception);
throw new FileException('Creating the directory failed.', $exception);
}
}
}
15 changes: 7 additions & 8 deletions src/Concurrent/ConcurrentFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Icicle\Coroutine\Coroutine;
use Icicle\Exception\InvalidArgumentError;
use Icicle\File\Exception\FileException;
use Icicle\File\Exception\FileTaskException;
use Icicle\File\File;
use Icicle\Stream\Exception\OutOfBoundsException;
use Icicle\Stream\Exception\UnreadableException;
Expand Down Expand Up @@ -159,7 +158,7 @@ public function read($length = 0, $byte = null, $timeout = 0)
$data = (yield $awaitable);
} catch (TaskException $exception) {
$this->close();
throw new FileTaskException('Reading from the file failed.', $exception);
throw new FileException('Reading from the file failed.', $exception);
}

$byte = (string) $byte;
Expand Down Expand Up @@ -252,7 +251,7 @@ protected function send($data, $timeout, $end = false)
}
} catch (TaskException $exception) {
$this->close();
throw new FileTaskException('Write to the file failed.', $exception);
throw new FileException('Write to the file failed.', $exception);
} finally {
if ($end) {
$this->close();
Expand Down Expand Up @@ -317,7 +316,7 @@ public function seek($offset, $whence = SEEK_SET, $timeout = 0)
$this->position = (yield $awaitable);
} catch (TaskException $exception) {
$this->close();
throw new FileTaskException('Seeking in the file failed.', $exception);
throw new FileException('Seeking in the file failed.', $exception);
}

if ($this->position > $this->size) {
Expand Down Expand Up @@ -362,7 +361,7 @@ public function truncate($size)
yield $this->worker->enqueue(new Internal\FileTask('ftruncate', [$size], $this->id));
} catch (TaskException $exception) {
$this->close();
throw new FileTaskException('Truncating the file failed.', $exception);
throw new FileException('Truncating the file failed.', $exception);
}

$this->size = $size;
Expand All @@ -387,7 +386,7 @@ public function stat()
yield $this->worker->enqueue(new Internal\FileTask('fstat', [], $this->id));
} catch (TaskException $exception) {
$this->close();
throw new FileTaskException('Stating file failed.', $exception);
throw new FileException('Stating file failed.', $exception);
}
}

Expand All @@ -403,7 +402,7 @@ public function copy($path)
try {
yield $this->worker->enqueue(new Internal\FileTask('copy', [$this->path, (string) $path]));
} catch (TaskException $exception) {
throw new FileTaskException('Copying the file failed.', $exception);
throw new FileException('Copying the file failed.', $exception);
}
}

Expand Down Expand Up @@ -449,7 +448,7 @@ private function change($operation, $value)
yield $this->worker->enqueue(new Internal\FileTask($operation, [$this->path, (int) $value]));
} catch (TaskException $exception) {
$this->close();
throw new FileTaskException(sprintf('%s failed.', $operation), $exception);
throw new FileException(sprintf('%s failed.', $operation), $exception);
}
}
}
9 changes: 8 additions & 1 deletion src/Exception/FileException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<?php
namespace Icicle\File\Exception;

class FileException extends \Exception implements Exception {}
class FileException extends \Exception implements Exception
{
public function __construct($message, \Exception $previous = null)
{
parent::__construct($message, 0, $previous);
}
}

10 changes: 0 additions & 10 deletions src/Exception/FileTaskException.php

This file was deleted.

0 comments on commit dda11ea

Please sign in to comment.