diff --git a/lib/AbstractException.php b/lib/AbstractException.php index 47caf39..967c338 100644 --- a/lib/AbstractException.php +++ b/lib/AbstractException.php @@ -104,8 +104,10 @@ abstract class AbstractException extends \Exception { "Rule/Exception.invalidPattern" => 10701, "CLI/Exception.pidNotFile" => 10801, "CLI/Exception.pidDirNotFound" => 10802, - "CLI/Exception.pidUnwritable" => 10803, - "CLI/Exception.pidUncreatable" => 10804, + "CLI/Exception.pidUnusable" => 10803, + "CLI/Exception.pidUnreadable" => 10804, + "CLI/Exception.pidUnwritable" => 10805, + "CLI/Exception.pidUncreatable" => 10806, ]; protected $symbol; diff --git a/lib/CLI.php b/lib/CLI.php index 433502e..1a17cc5 100644 --- a/lib/CLI.php +++ b/lib/CLI.php @@ -339,13 +339,17 @@ USAGE_TEXT; } elseif ($base = @realpath($dir)) { $out = "$base/$file"; if (file_exists($out)) { - if (!is_writable($out)) { - throw new \Exception("PID file is not writable"); + if (!is_readable($out) && !is_writable($out)) { + throw new CLI\Exception("pidUnusable", ['pidfile' => $out]); + } elseif (!is_readable($out)) { + throw new CLI\Exception("pidunreadable", ['pidfile' => $out]); + } elseif (!is_writable($out)) { + throw new CLI\Exception("pidUnwritable", ['pidfile' => $out]); } elseif (!is_file($out)) { throw new CLI\Exception("pidNotFile", ['pidfile' => $out]); } } elseif (!is_writable($base)) { - throw new \Exception("Cannot create PID file"); + throw new CLI\Exception("pidUncreatable", ['pidfile' => $out]); } } else { throw new \Exception("pidDirNotFound", ['piddir' => $dir]); diff --git a/locale/en.php b/locale/en.php index 66b9700..b93c53e 100644 --- a/locale/en.php +++ b/locale/en.php @@ -210,6 +210,9 @@ return [ 'Exception.JKingWeb/Arsse/Rule/Exception.invalidPattern' => 'Specified rule pattern is invalid', 'Exception.JKingWeb/Arsse/CLI/Exception.pidNotFile' => 'Specified PID file location "{pidfile}" must be a regular file', 'Exception.JKingWeb/Arsse/CLI/Exception.pidDirNotFound' => 'Parent directory "{piddir}" of PID file does not exist', + 'Exception.JKingWeb/Arsse/CLI/Exception.pidUnreadable' => 'Insufficient permissions to open PID file "{pidfile}" for reading', 'Exception.JKingWeb/Arsse/CLI/Exception.pidUnwritable' => 'Insufficient permissions to open PID file "{pidfile}" for writing', - 'Exception.JKingWeb/Arsse/CLI/Exception.pidNotFile' => 'Specified PID file location "{pidfile}" must be a regular file', + 'Exception.JKingWeb/Arsse/CLI/Exception.pidUnusable' => 'Insufficient permissions to open PID file "{pidfile}" for reading or writing', + 'Exception.JKingWeb/Arsse/CLI/Exception.pidUncreatable' => 'Insufficient permissions to create PID file "{pidfile}"', + 'Exception.JKingWeb/Arsse/CLI/Exception.pidNotFile' => 'PID file "{pidfile}" must be a regular file', ];