diff --git a/src/ParallelDriver.php b/src/ParallelDriver.php index fe12420..41eaa06 100644 --- a/src/ParallelDriver.php +++ b/src/ParallelDriver.php @@ -211,12 +211,12 @@ public function size(string $path): Promise return call(function () use ($path) { $stat = yield $this->stat($path); if (empty($stat)) { - throw new FilesystemException("Specified path does not exist"); + throw new PathDoesNotExistException($path); } if ($stat["mode"] & 0100000) { return $stat["size"]; } - throw new FilesystemException("Specified path is not a regular file"); + throw new FilesystemException(\sprintf('Specified path "%s" is not a regular file', $path)); }); } @@ -228,7 +228,7 @@ public function mtime(string $path): Promise return call(function () use ($path) { $stat = yield $this->stat($path); if (empty($stat)) { - throw new FilesystemException("Specified path does not exist"); + throw new PathDoesNotExistException($path); } return $stat["mtime"]; }); @@ -242,7 +242,7 @@ public function atime(string $path): Promise return call(function () use ($path) { $stat = yield $this->stat($path); if (empty($stat)) { - throw new FilesystemException("Specified path does not exist"); + throw new PathDoesNotExistException($path); } return $stat["atime"]; }); @@ -256,7 +256,7 @@ public function ctime(string $path): Promise return call(function () use ($path) { $stat = yield $this->stat($path); if (empty($stat)) { - throw new FilesystemException("Specified path does not exist"); + throw new PathDoesNotExistException($path); } return $stat["ctime"]; }); diff --git a/src/PathDoesNotExistException.php b/src/PathDoesNotExistException.php new file mode 100644 index 0000000..7c1dbef --- /dev/null +++ b/src/PathDoesNotExistException.php @@ -0,0 +1,19 @@ +path = $path; + parent::__construct(\sprintf('Specified path "%s" does not exist', $path)); + } + + public function getPath(): string + { + return $this->path; + } +}