par
jeff » 09 juin 2006, 17:53
salut
ca peut te donner des idée
//pour les exceptions non catché
function throwException2ErrorHandler($exception){
$ex = new defaultException($exception);
}
//pour les trigger
function throwTrigger2ErrorHandler($level, $message, $file = "", $line = "", $context = ""){
try{
throw new ApplicationControllerException( $message, $level);
}catch(ApplicationControllerException $e){}
}
et
<?php
class ApplicationControllerException extends Exception implements iException{
public function __construct($message,$code = 0 ){
parent::__construct($message,$code);
$error = ErrorHandler::singleton();
$error->startHandler($this);
}
final public function getInfo(){
return array ("info" => "PHP catched error", "file" => $this->getFile(), "line" => $this->getLine());
}
final public function getLevel(){
return $this->getCode();
}
final public function getBacktrace(){
return $this->getTrace();
}
}
?>
<?php
class defaultException extends Exception implements iException{
private $exception = null;
public function __construct($exception ){
$this->exception = $exception;
parent::__construct($this->exception->getMessage(),$this->exception->getCode());
$error = ErrorHandler::singleton();
$error->startHandler($this);
}
final public function getInfo(){
return array ("info" => "PHP catched error", "file" => $this->exception->getFile(), "line" => $this->exception->getLine());
}
final public function getLevel(){
return $this->exception->getCode();
}
final public function getBacktrace(){
return $this->exception->getTrace();
}
}
?>
ca ne marche peut etre pas tout a fait je l'ai fini ce matin
quant a la classe errorHandler géré l'affichage
note que ca repond a des besoin particulier d'un framework
pour ce qui de la surchage de contructeur je ne comprend pas ton pb etant donnée que php n'est pas typé
public function __construct($msg,$code=0) {
parent :: __construct($msg,$code);
}
il n'y a pas besoin d'autre paramatere