mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Start filling out PID file exceptions
This commit is contained in:
parent
372bf9f630
commit
9595c4f019
4 changed files with 23 additions and 5 deletions
|
@ -102,6 +102,10 @@ abstract class AbstractException extends \Exception {
|
||||||
"ImportExport/Exception.invalidFolderCopy" => 10614,
|
"ImportExport/Exception.invalidFolderCopy" => 10614,
|
||||||
"ImportExport/Exception.invalidTagName" => 10615,
|
"ImportExport/Exception.invalidTagName" => 10615,
|
||||||
"Rule/Exception.invalidPattern" => 10701,
|
"Rule/Exception.invalidPattern" => 10701,
|
||||||
|
"CLI/Exception.pidNotFile" => 10801,
|
||||||
|
"CLI/Exception.pidDirNotFound" => 10802,
|
||||||
|
"CLI/Exception.pidUnwritable" => 10803,
|
||||||
|
"CLI/Exception.pidUncreatable" => 10804,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $symbol;
|
protected $symbol;
|
||||||
|
|
|
@ -331,24 +331,24 @@ USAGE_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resolves the PID file path and ensures the file or parent directory is writable */
|
/** Resolves the PID file path and ensures the file or parent directory is writable */
|
||||||
protected function resolvePID(string $pidfile): string {
|
public function resolvePID(string $pidfile): string {
|
||||||
$dir = dirname($pidfile);
|
$dir = dirname($pidfile);
|
||||||
$file = basename($pidfile);
|
$file = basename($pidfile);
|
||||||
if (!strlen($file)) {
|
if (!strlen($file)) {
|
||||||
throw new \Exception("Specified PID file location must be a regular file");
|
throw new CLI\Exception("pidNotFile", ['pidfile' => $dir]);
|
||||||
} elseif ($base = @realpath($dir)) {
|
} elseif ($base = @realpath($dir)) {
|
||||||
$out = "$base/$file";
|
$out = "$base/$file";
|
||||||
if (file_exists($out)) {
|
if (file_exists($out)) {
|
||||||
if (!is_writable($out)) {
|
if (!is_writable($out)) {
|
||||||
throw new \Exception("PID file is not writable");
|
throw new \Exception("PID file is not writable");
|
||||||
} elseif (!is_file($out)) {
|
} elseif (!is_file($out)) {
|
||||||
throw new \Exception("Specified PID file location must be a regular file");
|
throw new CLI\Exception("pidNotFile", ['pidfile' => $out]);
|
||||||
}
|
}
|
||||||
} elseif (!is_writable($base)) {
|
} elseif (!is_writable($base)) {
|
||||||
throw new \Exception("Cannot create PID file");
|
throw new \Exception("Cannot create PID file");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception("Parent directory of PID file does not exist");
|
throw new \Exception("pidDirNotFound", ['piddir' => $dir]);
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
10
lib/CLI/Exception.php
Normal file
10
lib/CLI/Exception.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
/** @license MIT
|
||||||
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
||||||
|
* See LICENSE and AUTHORS files for details */
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
namespace JKingWeb\Arsse\CLI;
|
||||||
|
|
||||||
|
class Exception extends \JKingWeb\Arsse\AbstractException {
|
||||||
|
}
|
|
@ -207,5 +207,9 @@ return [
|
||||||
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidFolderName' => 'Input data contains an invalid folder name',
|
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidFolderName' => 'Input data contains an invalid folder name',
|
||||||
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidFolderCopy' => 'Input data contains multiple folders of the same name under the same parent',
|
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidFolderCopy' => 'Input data contains multiple folders of the same name under the same parent',
|
||||||
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidTagName' => 'Input data contains an invalid tag name',
|
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidTagName' => 'Input data contains an invalid tag name',
|
||||||
'Exception.JKingWeb/Arsse/Rule/Exception.invalidPattern' => 'Specified rule pattern is invalid'
|
'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.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',
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue