1 | <?php |
||
15 | class CondorcetException extends \Exception |
||
16 | { |
||
17 | use CondorcetVersion; |
||
18 | |||
19 | public const CODE_RANGE = [0,1000]; |
||
20 | |||
21 | public const EXCEPTION_CODE = [ |
||
22 | 1 => 'Bad candidate format', |
||
23 | 2 => 'The voting process has already started', |
||
24 | 3 => 'This candidate ID is already registered', |
||
25 | 4 => 'This candidate ID do not exist', |
||
26 | 5 => 'Bad vote format | {{ infos1 }}', |
||
27 | 6 => 'You need to specify votes before results', |
||
28 | 7 => 'Your Candidate ID is too long > {{ infos1 }}', |
||
29 | 8 => 'This method do not exist', |
||
30 | 9 => 'The algo class you want has not been defined', |
||
31 | 10 => 'The algo class you want is not correct', |
||
32 | 11 => 'You try to unserialize an object version older than your actual Class version. This is a problematic thing', |
||
33 | 12 => 'You have exceeded the number of votes allowed for this method.', |
||
34 | 13 => 'Formatting error: You must specify an integer', |
||
35 | 14 => 'parseVote() must take a string (raw or path) as argument', |
||
36 | 15 => 'Input must be valid Json format', |
||
37 | 16 => 'You have exceeded the maximum number of votes allowed per election ({{ infos1 }}).', |
||
38 | 17 => 'Bad tags input format', |
||
39 | 18 => 'New vote can\'t match Candidate of his elections', |
||
40 | 19 => 'This name is not allowed in because of a namesake in the election in which the object participates.', |
||
41 | 20 => 'You need to specify one or more candidates before voting', |
||
42 | 21 => 'Bad vote timestamp format', |
||
43 | 22 => 'This context is not valid', |
||
44 | 23 => 'No Data Handler in use', |
||
45 | 24 => 'A Data Handler is already in use', |
||
46 | 25 => 'Algo class try to use existing alias', |
||
47 | 26 => 'Weight can not be < 1', |
||
48 | 27 => 'The vote constraint class you want has not been defined', |
||
49 | 28 => 'The vote constraint class you want is not correct', |
||
50 | 29 => 'This vote constraint is already registered', |
||
51 | 30 => 'You can\'t add constraint after starting to record votes ', |
||
52 | 31 => 'Vote object already registred', |
||
53 | 32 => 'Invalid Input', |
||
54 | |||
55 | // DataManager |
||
56 | 50 => 'This entity does not exist.', |
||
57 | |||
58 | // Algo. |
||
59 | 102 => 'Marquis of Condorcet algortihm can\'t provide a full ranking. But only Winner and Loser.' |
||
60 | ]; |
||
61 | |||
62 | protected $_infos; |
||
63 | |||
64 | 43 | public function __construct (int $code = 0, string ...$infos) |
|
74 | |||
75 | public function __toString () : string |
||
79 | |||
80 | 43 | protected function correspondence (int $code) : string |
|
93 | } |
||
94 |