forked from supervisorphp/supervisor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFault.php
More file actions
79 lines (74 loc) · 2.46 KB
/
Fault.php
File metadata and controls
79 lines (74 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Supervisor\Exception;
/**
* Fault codes are taken from the source code, not the documentation.
* The most common ones are covered by the XML-RPC doc.
*
* @link http://supervisord.org/api.html
*
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
*/
class Fault extends \Exception
{
/**
* Fault responses.
*/
const UNKNOWN_METHOD = 1;
const INCORRECT_PARAMETERS = 2;
const BAD_ARGUMENTS = 3;
const SIGNATURE_UNSUPPORTED = 4;
const SHUTDOWN_STATE = 6;
const BAD_NAME = 10;
const BAD_SIGNAL = 11;
const NO_FILE = 20;
const NOT_EXECUTABLE = 21;
const FAILED = 30;
const ABNORMAL_TERMINATION = 40;
const SPAWN_ERROR = 50;
const ALREADY_STARTED = 60;
const NOT_RUNNING = 70;
const SUCCESS = 80;
const ALREADY_ADDED = 90;
const STILL_RUNNING = 91;
const CANT_REREAD = 92;
/**
* @var array
*/
private static $exceptionMap = [
1 => 'Supervisor\Exception\Fault\UnknownMethod',
2 => 'Supervisor\Exception\Fault\IncorrectParameters',
3 => 'Supervisor\Exception\Fault\BadArguments',
4 => 'Supervisor\Exception\Fault\SignatureUnsupported',
6 => 'Supervisor\Exception\Fault\ShutdownState',
10 => 'Supervisor\Exception\Fault\BadName',
11 => 'Supervisor\Exception\Fault\BadSignal',
20 => 'Supervisor\Exception\Fault\NoFile',
21 => 'Supervisor\Exception\Fault\NotExecutable',
30 => 'Supervisor\Exception\Fault\Failed',
40 => 'Supervisor\Exception\Fault\AbnormalTermination',
50 => 'Supervisor\Exception\Fault\SpawnError',
60 => 'Supervisor\Exception\Fault\AlreadyStarted',
70 => 'Supervisor\Exception\Fault\NotRunning',
80 => 'Supervisor\Exception\Fault\Success',
90 => 'Supervisor\Exception\Fault\AlreadyAdded',
91 => 'Supervisor\Exception\Fault\StillRunning',
92 => 'Supervisor\Exception\Fault\CantReread',
];
/**
* Creates a new Fault.
*
* If there is a mach for the fault code in the exception map then the matched exception will be returned
*
* @param string $faultString
* @param int $faultCode
*
* @return self
*/
public static function create($faultString, $faultCode)
{
if (!isset(self::$exceptionMap[$faultCode])) {
return new self($faultString, $faultCode);
}
return new self::$exceptionMap[$faultCode]($faultString, $faultCode);
}
}