Project

General

Profile

« Previous | Next » 

Revision 1670

Added by darkviper about 12 years ago

added new global exceptionhandler (class AppException)

View differences:

globalExceptionHandler.php
16 16
/**
17 17
 * define several default exceptions directly to prevent from extra loading requests
18 18
 */
19

  
20 19
/**
20
 * 
21
 */
22
	class AppException extends Exception{
23
		public function __toString() {
24
			$file = str_replace(dirname(dirname(__FILE__)), '', $this->getFile());
25
			if(DEBUG) {
26
				$trace = $this->getTrace();
27
				$result = 'Exception: "'.$this->getMessage().'" @ ';
28
				if($trace[0]['class'] != '') {
29
				  $result .= $trace[0]['class'].'->';
30
				}
31
				$result .= $trace[0]['function'].'(); in'.$file.'<br />'."\n";
32
				if(mysql_errno()) {
33
					$result .= mysql_errno().': '.mysql_error().'<br />'."\n";
34
				}
35
			}else {
36
				$result = 'Exception: "'.$this->getMessage().'" in ['.$file.']<br />'."\n";
37
			}
38
			return $result;
39
		}
40
	}
41
/**
21 42
 * define Exception to show error after accessing a forbidden file
22 43
 */
23 44
	class IllegalFileException extends LogicException {

Also available in: Unified diff