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