Example #1
0
 public function testExceptionText_noticesPreviousException()
 {
     $text = Exception::getExceptionText($this->createFullException(), 'text');
     $this->assertContains('Previous Exception', $text);
     $html = Exception::getExceptionText($this->createFullException(), 'html');
     $this->assertContains('Previous Exception', $html);
 }
Example #2
0
 protected function log(\Exception $e, $contextInfo = NULL)
 {
     if ($e instanceof \ErrorException) {
         $errorType = self::$errors[$e->getSeverity()];
     } else {
         $errorType = Code::getClass($e);
     }
     // wir müssen hier den error selbst loggen, da php nichts mehr macht (die faule banane)
     $php = NULL;
     $php .= 'PHP ' . $errorType . ': ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
     $php .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     error_log($php, 0);
     /* Debug-Mail */
     $debug = NULL;
     $debug .= '[' . date('d.M.Y H:i:s') . "] ";
     $debug .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     if ($e instanceof \Psc\Code\ErrorException) {
         $debug .= "\n" . $e->contextDump;
     }
     if (isset($contextInfo)) {
         $debug .= "\nContextInfo: \n" . $contextInfo;
     }
     if (isset($this->recipient) && !PSC::inTests()) {
         if ($ret = @mail($this->recipient, '[Psc-ErrorHandler] [' . $e->getCode() . '] ' . $e->getMessage(), $debug, 'From: www@' . PSC::getEnvironment()->getHostName() . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n") === FALSE) {
             error_log('[\\Psc\\Code\\ErrorHandler.php:' . __LINE__ . '] Die Fehlerinformationen konnten nicht an den lokalen Mailer übergeben werden.', 0);
         }
     }
 }
Example #3
0
 public function logError(\Exception $e, $detailLevel = 1, $level = 1)
 {
     if ($detailLevel >= 5) {
         return $this->log("\n" . 'ERROR: ' . \Psc\Exception::getExceptionText($e, 'text'));
     } else {
         return $this->log("\n" . 'ERROR: Exception: ' . $e->getMessage(), $level);
     }
 }
Example #4
0
 /**
  * Fügt eine schöne Exception als Fehler hinzu
  */
 public function addEx(\Psc\Exception $e)
 {
     if (isset($e->errorMessage)) {
         $msg = $e->errorMessage;
     } else {
         $msg = $e->getMessage();
     }
     if (isset($e->errorStatus)) {
         $errorStatus = $e->errorStatus;
     } else {
         $errorStatus = self::ERROR;
     }
     $devInfo = NULL;
     if (PSC::getProject()->isDevelopment()) {
         $devInfo = \Psc\Exception::getExceptionText($e, 'html');
     }
     return $this->add($msg, $errorStatus, $devInfo);
 }