ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
CrawlerException.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
6 
14 class CrawlerException extends \Exception
15 {
16  const UNKNOWN_EXCEPTION = -1;
17 
18  const ARRAY_EXPECTED = 1000;
19  const STRING_EXPECTED = 1001;
20  const INVALID_TYPE = 1002;
21  const EMPTY_STRING = 1002;
22 
23  const EMPTY_ENTRY = 2000;
25  const DUPLICATE_ENTRY = 2002;
26  const DUPLICATE_ROOT_ENTRY = 2003;
27  const INVALID_ID = 2004;
28  const INVALID_FILE_PATH = 2005;
29  const INVALID_RULES_ENTRY = 2006;
33  const ENTRY_TITLE_MISSING = 2010;
34  const ENTRY_WITHOUT_FUNCTION = 2011;
35 
36  const FILE_CREATION_FAILED = 3000;
37  const FOLDER_CREATION_FAILED = 3001;
38  const FILE_OPENING_FAILED = 3002;
39  const LESS_COMPILE_FAILED = 3003;
40  const FOLDER_DELETION_FAILED = 3004;
41  const FILE_DELETION_FAILED = 3005;
42 
43  const INVALID_INDEX = 4000;
44  const MISSING_INDEX = 4001;
45 
47 
51  protected $message = "";
52 
56  protected $code = -1;
57 
61  protected $add_info = "";
62 
69  public function __construct($exception_code = -1, $exception_info = "")
70  {
71  $this->add_info = $exception_info;
72  $this->code = $exception_code;
73  $this->assignMessageToCode();
74  parent::__construct($this->message, $exception_code);
75  }
76 
77  protected function assignMessageToCode()
78  {
79  switch ($this->code) {
80  case self::ARRAY_EXPECTED:
81  $this->message = "Array was expected, got " . $this->add_info;
82  break;
83  case self::STRING_EXPECTED:
84  $this->message = "String was expected, got " . $this->add_info;
85  break;
86  case self::INVALID_TYPE:
87  $this->message = "Invalid type: " . $this->add_info;
88  break;
89  case self::EMPTY_STRING:
90  $this->message = "String can not be empty: " . $this->add_info;
91  break;
92 
93  case self::EMPTY_ENTRY:
94  $this->message = "Empty Entry " . $this->add_info;
95  break;
96  case self::INVALID_MANDATORY_ENTRY_ATTRIBUTE:
97  $this->message = "Invalid mandatory entry Attribute: " . $this->add_info;
98  break;
99  case self::DUPLICATE_ENTRY:
100  $this->message = "There are entries with the same ID. Duplicate: " . $this->add_info;
101  break;
102  case self::DUPLICATE_ROOT_ENTRY:
103  $this->message = "There are multiple root entry. Duplicate: " . $this->add_info;
104  break;
105  case self::INVALID_ID:
106  $this->message = "No such ID in tree: " . $this->add_info;
107  break;
108  case self::ENTRY_WITH_NO_YAML_DESCRIPTION:
109  $this->message = "No YAML Description found for Entry returned by: '" . $this->add_info .
110  "' (check if the entry is properly introduced and closed with '---' before return statement)";
111  break;
112  case self::ENTRY_WITH_NO_VALID_RETURN_STATEMENT:
113  $this->message = "No Return statement given for Entry: " . $this->add_info;
114  break;
115  case self::PARSING_YAML_ENTRY_FAILED:
116  $this->message = "Parsing Yaml entry failed: " . $this->add_info;
117  break;
118  case self::ENTRY_TITLE_MISSING:
119  $this->message = "Entry Title missing (check if valid function name is set for all entries): " . $this->add_info;
120  break;
121  case self::ENTRY_WITHOUT_FUNCTION:
122  $this->message = "Entry Function missing: " . $this->add_info;
123  break;
124 
125  case self::INVALID_FILE_PATH:
126  $this->message = "Invalid file path or file not readable: " . $this->add_info;
127  break;
128  case self::FILE_CREATION_FAILED:
129  $this->message = "File creation failed, path: " . $this->add_info;
130  break;
131  case self::FOLDER_CREATION_FAILED:
132  $this->message = "Folder creation failed, path: " . $this->add_info;
133  break;
134  case self::FOLDER_DELETION_FAILED:
135  $this->message = "Folder delation failed, path: " . $this->add_info;
136  break;
137  case self::FILE_DELETION_FAILED:
138  $this->message = "File delation failed, path: " . $this->add_info;
139  break;
140  case self::LESS_COMPILE_FAILED:
141  $this->message = "Compilation of less failed: " . $this->add_info;
142  break;
143  case self::FILE_OPENING_FAILED:
144  $this->message = "Failed to open file : " . $this->add_info;
145  break;
146 
147  case self::INVALID_INDEX:
148  $this->message = "Invalid index: " . $this->add_info;
149  break;
150  case self::MISSING_INDEX:
151  $this->message = "Missing index in class: " . $this->add_info;
152  break;
153  case self::CRAWL_MAX_NESTING_REACHED:
154  $this->message = "Max nesting reached while crowling (Factories might contain a circle), info: " . $this->add_info;
155  break;
156 
157  case self::UNKNOWN_EXCEPTION:
158  default:
159  $this->message = "Unknown Exception " . $this->add_info;
160  break;
161  }
162  }
163 
164  public function __toString()
165  {
166  return get_class($this) . " '{$this->message}' in {$this->file}({$this->line})\n"
167  . "{$this->getTraceAsString()}";
168  }
169 }
__construct($exception_code=-1, $exception_info="")
ilKitchenSinkException constructor.