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
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 protected function assignMessageToCode()
78 {
79 switch ($this->code) {
81 $this->message = "Array was expected, got " . $this->add_info;
82 break;
84 $this->message = "String was expected, got " . $this->add_info;
85 break;
87 $this->message = "Invalid type: " . $this->add_info;
88 break;
90 $this->message = "String can not be empty: " . $this->add_info;
91 break;
92
94 $this->message = "Empty Entry " . $this->add_info;
95 break;
97 $this->message = "Invalid mandatory entry Attribute: " . $this->add_info;
98 break;
100 $this->message = "There are entries with the same ID. Duplicate: " . $this->add_info;
101 break;
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;
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;
113 $this->message = "No Return statement given for Entry: " . $this->add_info;
114 break;
116 $this->message = "Parsing Yaml entry failed: " . $this->add_info;
117 break;
119 $this->message = "Entry Title missing (check if valid function name is set for all entries): " . $this->add_info;
120 break;
122 $this->message = "Entry Function missing: " . $this->add_info;
123 break;
124
126 $this->message = "Invalid file path or file not readable: " . $this->add_info;
127 break;
129 $this->message = "File creation failed, path: " . $this->add_info;
130 break;
132 $this->message = "Folder creation failed, path: " . $this->add_info;
133 break;
135 $this->message = "Folder delation failed, path: " . $this->add_info;
136 break;
138 $this->message = "File delation failed, path: " . $this->add_info;
139 break;
141 $this->message = "Compilation of less failed: " . $this->add_info;
142 break;
144 $this->message = "Failed to open file : " . $this->add_info;
145 break;
146
148 $this->message = "Invalid index: " . $this->add_info;
149 break;
151 $this->message = "Missing index in class: " . $this->add_info;
152 break;
154 $this->message = "Max nesting reached while crowling (Factories might contain a circle), info: " . $this->add_info;
155 break;
156
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}
An exception for terminatinating execution or to throw for unit testing.
__construct($exception_code=-1, $exception_info="")
ilKitchenSinkException constructor.