All pastes #1275689 Raw Edit

sskaje

public php v1 · immutable
#1275689 ·published 2008-12-04 08:39 UTC
rendered paste body
<?php/** * Exception Handler * */final class ISCC_Exceptionhandler extends ISCC_Component // implements ISCC_Singleton_interface {	private function __construct()	{	}	/**	 * 自定义异常	 *	 */	static public function custom_exception_handler()	{		set_exception_handler(array(__CLASS__, 'exception_handler'));	}	static public function exception_handler($exception)	{		if ($exception instanceof ISCC_Exception_User )		{			self::$iscclass->msgbox('User Exception',$exception->show_error());		}		else if ($exception instanceof ISCC_Exception_DB )		{			self::$iscclass->msgbox('DB Exception', $exception->show_error());		}		else if ($exception instanceof ISCC_Exception_Challenge  )		{			self::$iscclass->msgbox('Mission Exception',$exception->show_error());		}		else if ($exception instanceof ISCC_Exception_Security ) 		{			trigger_error("Security Exception?  ".$exception->show_error()."\n", E_USER_ERROR);		}		else		{			echo $exception->show_error();		//	self::$iscclass->msgbox('What Exception', $exception->show_error());		}	}}/** * Exception Class (base) * */class ISCC_Exception extends Exception {	public function __construct($message, $code = 0) 	{		parent::__construct($message, $code);	}		public function show_error()	{		return $this->getMessage();	}}/** * Basic Exception * 一般不好放的异常都扔这儿 * */class ISCC_Exception_Default extends ISCC_Exception {	public function __construct($message, $code = 0) 	{		parent::__construct($message, $code);	}}/** * DataBase related Exception * 数据库异常,根据系统设置,来决定是否显示数据库错误 * */class ISCC_Exception_DB extends ISCC_Exception  {	private $errno;	private $error;	/**	 * ISCC_Exception_DB	 *	 * @param string $message	 * @param int $code	 * @param mysqli $mysqli	 */	public function __construct($message, $code = 0, &$mysqli) 	{		parent::__construct($message, $code);		$this->errno = $mysqli->errno;		$this->error = $mysqli->error;	}		public function show_error()	{		if (ISCC_DBDEBUG) 		{			return $this->getMessage() . '<br /> [DB Error: #'.$this->errno .' ' . $this->error .']';		}		else 		{			return $this->getMessage();		}	}}/** * Auth Exception * 用于不合法的身份/权限认证 * */class ISCC_Exception_Auth extends ISCC_Exception {	public function __construct($message, $code = 0) 	{		parent::__construct($message, $code);	}}/** * Exception for Variable * 变量类型错误 * */class ISCC_Exception_Variable extends ISCC_Exception{	public function __construct($message, $code = 0) 	{		parent::__construct($message, $code);	}}/** * 安全相关Exception * */class ISCC_Exception_Security extends ISCC_Exception {	function __construct($message, $code=0) 	{		parent::__construct($message, $code);	}}/** * 系统级异常 * */class ISCC_Exception_System extends ISCC_Exception  {	function __construct($message, $code=0)	{		parent::__construct($message, $code);	}}?>