hotti: Warnungen und Notizen in den Status einer Exception erheben

Beitrag lesen

hi,

Aber wie gesagt, es geht viel einfacher, wenn man die eingebauten Mechanismen nutzte.

Ja, das interessiert mich.

class ErrorException extends Exception {

protected $context = array();

public function __construct($no, $msg, $file, $line, $context){
    parent::__construct($msg, $no);
    $this->file = $file; // Datei und Zeile setzen, sonst sind das die Werte vom throw im ErrorHandler
    $this->line = $line;
    $this->context = $context;
  }

public static function ErrorHandler($no, $msg, $file, $line, $context) {
    if (error_reporting())
      throw new ExException($no, $msg, $file, $line, $context);
    return true;
  }
}

set_error_handler("ErrorException::ErrorHandler");

  
Leider bekomme ich:  
PHP Fatal error:  Cannot redeclare class ErrorException in D:\home\dev\error\_handler.php on line 18  
  
Wo ist der Fehler?  
Hotti