ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
78  protected function assignMessageToCode()
79  {
80  switch ($this->code)
81  {
82  case self::ARRAY_EXPECTED:
83  $this->message = "Array was expected, got " . $this->add_info;
84  break;
85  case self::STRING_EXPECTED:
86  $this->message = "String was expected, got " . $this->add_info;
87  break;
88  case self::INVALID_TYPE:
89  $this->message = "Invalid type: " . $this->add_info;
90  break;
91  case self::EMPTY_STRING:
92  $this->message = "String can not be empty: " . $this->add_info;
93  break;
94 
95  case self::EMPTY_ENTRY:
96  $this->message = "Empty Entry " . $this->add_info;
97  break;
98  case self::INVALID_MANDATORY_ENTRY_ATTRIBUTE:
99  $this->message = "Invalid mandatory entry Attribute: " . $this->add_info;
100  break;
101  case self::DUPLICATE_ENTRY:
102  $this->message = "There are entries with the same ID. Duplicate: " . $this->add_info;
103  break;
104  case self::DUPLICATE_ROOT_ENTRY:
105  $this->message = "There are multiple root entry. Duplicate: " . $this->add_info;
106  break;
107  case self::INVALID_ID:
108  $this->message = "No such ID in tree: " . $this->add_info;
109  break;
110  case self::ENTRY_WITH_NO_YAML_DESCRIPTION:
111  $this->message = "No YAML Description found for Entry returned by: '" . $this->add_info.
112  "' (check if the entry is properly introduced and closed with '---' before return statement)";
113  break;
114  case self::ENTRY_WITH_NO_VALID_RETURN_STATEMENT:
115  $this->message = "No Return statement given for Entry: " . $this->add_info;
116  break;
117  case self::PARSING_YAML_ENTRY_FAILED:
118  $this->message = "Parsing Yaml entry failed: " . $this->add_info;
119  break;
120  case self::ENTRY_TITLE_MISSING:
121  $this->message = "Entry Title missing (check if valid function name is set for all entries): " . $this->add_info;
122  break;
123  case self::ENTRY_WITHOUT_FUNCTION:
124  $this->message = "Entry Function missing: " . $this->add_info;
125  break;
126 
127  case self::INVALID_FILE_PATH:
128  $this->message = "Invalid file path or file not readable: " . $this->add_info;
129  break;
130  case self::FILE_CREATION_FAILED:
131  $this->message = "File creation failed, path: " . $this->add_info;
132  break;
133  case self::FOLDER_CREATION_FAILED:
134  $this->message = "Folder creation failed, path: " . $this->add_info;
135  break;
136  case self::FOLDER_DELETION_FAILED:
137  $this->message = "Folder delation failed, path: " . $this->add_info;
138  break;
139  case self::FILE_DELETION_FAILED:
140  $this->message = "File delation failed, path: " . $this->add_info;
141  break;
142  case self::LESS_COMPILE_FAILED:
143  $this->message = "Compilation of less failed: " . $this->add_info;
144  break;
145  case self::FILE_OPENING_FAILED:
146  $this->message = "Failed to open file : " . $this->add_info;
147  break;
148 
149  case self::INVALID_INDEX:
150  $this->message = "Invalid index: " . $this->add_info;
151  break;
152  case self::MISSING_INDEX:
153  $this->message = "Missing index in class: " . $this->add_info;
154  break;
155  case self::CRAWL_MAX_NESTING_REACHED:
156  $this->message = "Max nesting reached while crowling (Factories might contain a circle), info: " . $this->add_info;
157  break;
158 
159  case self::UNKNOWN_EXCEPTION:
160  default:
161  $this->message = "Unknown Exception " . $this->add_info;
162  break;
163  }
164  }
165 
166  public function __toString()
167  {
168  return get_class($this) . " '{$this->message}' in {$this->file}({$this->line})\n"
169  . "{$this->getTraceAsString()}";
170  }
171 }
__construct($exception_code=-1, $exception_info="")
ilKitchenSinkException constructor.