Error Handling

Allikas: Juhised

For error handling, there is a class called Error. config.php contains all the error type codes beginning with ERROR_TYPE.... At least every database query must be checked for the errors.

Sometimes, if there happens an error case, a fatal error will be executed by telling that the allowed memory size is exhausted. Then, it is not permitted to use another type code but ERROR_TYPE_SEND_MAIL. Otherwise, the erroneous function will be called endlessly by creating the page for the user because the page creation calls the same method. Once discovered an error case, it tries to build up the error page but during this process, the same error case happens again.

If we use a function that can raise an error inside itself and we cannot avoid the PHP engine's error message on the screen otherwise then we catch that error so:

					require_once dirname(__FILE__) . '/../../lib/PHP/Exceptionizer.php';
					$exceptionizer = new PHP_Exceptionizer(E_ALL);
						$uploaded = move_uploaded_file($_FILES['logo']['tmp_name'], $uploadfile);
					catch (E_WARNING $e)
						require_once dirname(__FILE__) . '/../../Error.php';
						new Error(
								'Viga <em>%1$s</em>
								ilmnes failis <em>%3$s</em>
								real <em>%4$s</em>:<br/>
								$e->getMessage(), // 1
								$e->getCode(), // 2
								$e->getFile(), // 3
								$e->getLine(), // 4
								$e->getTraceAsString() // 5