All pastes #372832 Raw Edit

Miscellany

public text v1 · immutable
#372832 ·published 2007-02-26 09:35 UTC
rendered paste body
<?php
/**
 * @author Jerome Izard
 * @version 1.0
 * @package package_name 
 */
class MyException extends Exception
{
	public function __construct($msg, $code=NULL, $file=NULL, $line=NULL, $context=NULL)
	{
		parent::__construct($msg);
		
		if(isset($code)) $this->code = $code;
		if(isset($line)) $this->line = $line;
		if(isset($file)) $this->file = $file;
		if(isset($context)) $this->context = $context;
	}

	public function getError()
	{
		$return  = '<p class="exception">Une exception a été générée : <br />';
		$return .= '<strong>Message : ' . $this->getMessage() . '</strong><br />';
		$return .= 'A la ligne : ' . $this->getLine() . '<br />';
		$return .= 'Dans le fichier : ' . $this->getFile() . '</p>';
		
		return $return;
    }
}

function myErrorHandler($code, $msg, $file, $line, $context)
{
	throw new MyException($msg, $code, $file, $line, $context);
}
set_error_handler('myErrorHandler');
?>