<?php


class MyException extends Exception
{
	private $developerMsg=NULL;
	private $userMsg=NULL;
	private $errorCode=NULL;
	
	public function __construct($exception_id, $tokens = array()) {
		$list = func_get_args();
		if(isset($list[1]) && is_string($list[1]))
		{
			echo 'Exception in file "'.$this->getFile().'" on line no "'.$this->getLine().'"<br/>';
			echo '<h1>'.$list[1].'</h1>';
			exit;
		}
		else
		{
			$query ="SELECT * FROM user_exceptions WHERE id =".$exception_id;
			
			$queryOb = new classQueryGlobal;
			$message = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
			
			
			if(is_array($tokens))
			{
				foreach($tokens as $key => $value)
				{
					$message[0]['developer_msg'] = str_replace('{'.$key.'}', $value, $message[0]['developer_msg']);
					$message[0]['user_msg'] = str_replace('{'.$key.'}', $value, $message[0]['user_msg']);
				}
			}
			
			$this->developerMsg = 'Error # '.$message[0]['id']." : ".addslashes($message[0]['developer_msg']);
			$this->userMsg = 'Error # '.$message[0]['id']." : ".$message[0]['user_msg'];
			
			$this->errorCode = $exception_id;
			
			
		}
	}
	
	public  function getErrorCode(){
			return $this->errorCode;
	}
	
	public  function getDeveloperMsg(){
			return $this->developerMsg;
	}
	
	public  function getUserMsg(){
			return $this->userMsg;
	}
	
}


/*class MyException extends Exception
{
	private $developerMsg=NULL;
	private $userMsg=NULL;
	
	public function __construct($developerMsg, $userMsg = "") {
		$this->developerMsg = addslashes($developerMsg);
		$this->userMsg = $userMsg;
		
		//classLogGlobal::setSecurityLog($this->developerMsg,"exception", 1);
    }	
	
	public  function getDeveloperMsg(){
			return $this->developerMsg;
	}
	
	public  function getUserMsg(){
			return $this->userMsg;
	}
	
}
*/



?>