class_mcException.inc.php 1.3 KB
<?php
/** 
 * @copyright (c) 2014, netz.coop eG
 */

class mcException extends mcEvent  {

	public static function handleException (Exception $e) {
//		D::h2('Exception Error ('.$e->getCode().') in '.$e->getFile().' in row '.$e->getLine());
//		D::e('Message: '.$e->getMessage().' '.  c.'<br>');
//		D::show($e->getTraceAsString(), 'TraceAsString');
//		if($e->getPrevious()) {
//			D::e('there is a previous exception');
//		}
		D::cf('ERROR', D::ALL);
		if(get_class($e) == 'PDOException') {
			foreach($e->getTrace() as $i => $array) {
//				D::li($i);
				if(array_key_exists('args', $array)) {
					$out1 = null;
					foreach($array['args'] as $arg) {
						if(get_class ($arg) == 'PDOStatement') {
							ob_start();
							$arg->debugDumpParams();
							$out1 = ob_get_contents();
							ob_end_clean();
//							D::ulli($out1);
							break;
						}
					}
					if($out1) {
						break;
					}
				}
			}
		}
		self::handle(E_ERROR, $e->getCode(), $e->getFile(), $e->getLine(), $e->getMessage().mcCONST::LINEBREAK.$out1);
		return false;
	}
	public static $count =0;
	private static function handle($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext) {
		self::add(new mcException($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext));
		
		self::$count++;
	}
}
?>