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
14class CrawlerException extends \Exception
15{
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;
27 const INVALID_ID = 2004;
28 const INVALID_FILE_PATH = 2005;
29 const INVALID_RULES_ENTRY = 2006;
33 const ENTRY_TITLE_MISSING = 2010;
35
38 const FILE_OPENING_FAILED = 3002;
39 const LESS_COMPILE_FAILED = 3003;
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 {
83 $this->message = "Array was expected, got " . $this->add_info;
84 break;
86 $this->message = "String was expected, got " . $this->add_info;
87 break;
89 $this->message = "Invalid type: " . $this->add_info;
90 break;
92 $this->message = "String can not be empty: " . $this->add_info;
93 break;
94
96 $this->message = "Empty Entry " . $this->add_info;
97 break;
99 $this->message = "Invalid mandatory entry Attribute: " . $this->add_info;
100 break;
102 $this->message = "There are entries with the same ID. Duplicate: " . $this->add_info;
103 break;
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;
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;
115 $this->message = "No Return statement given for Entry: " . $this->add_info;
116 break;
118 $this->message = "Parsing Yaml entry failed: " . $this->add_info;
119 break;
121 $this->message = "Entry Title missing (check if valid function name is set for all entries): " . $this->add_info;
122 break;
124 $this->message = "Entry Function missing: " . $this->add_info;
125 break;
126
128 $this->message = "Invalid file path or file not readable: " . $this->add_info;
129 break;
131 $this->message = "File creation failed, path: " . $this->add_info;
132 break;
134 $this->message = "Folder creation failed, path: " . $this->add_info;
135 break;
137 $this->message = "Folder delation failed, path: " . $this->add_info;
138 break;
140 $this->message = "File delation failed, path: " . $this->add_info;
141 break;
143 $this->message = "Compilation of less failed: " . $this->add_info;
144 break;
146 $this->message = "Failed to open file : " . $this->add_info;
147 break;
148
150 $this->message = "Invalid index: " . $this->add_info;
151 break;
153 $this->message = "Missing index in class: " . $this->add_info;
154 break;
156 $this->message = "Max nesting reached while crowling (Factories might contain a circle), info: " . $this->add_info;
157 break;
158
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}
An exception for terminatinating execution or to throw for unit testing.
__construct($exception_code=-1, $exception_info="")
ilKitchenSinkException constructor.