public function testGetAttributes()
 {
     $this->assertEquals('error_type', $this->error->getType());
     $this->assertEquals('error_file', $this->error->getFile());
     $this->assertEquals('error_line', $this->error->getLine());
     $this->assertEquals('error_char', $this->error->getChar());
     $this->assertEquals('error_code', $this->error->getCode());
 }
 public function test()
 {
     $error = new Error(E_ERROR, 'message', 'file', 0);
     $this->assertSame(E_ERROR, $error->getSeverity());
     $this->assertSame('message', $error->getMessage());
     $this->assertSame('Fatal error', $error->getSeverityAsString());
     $this->assertSame('E_ERROR', $error->getSeverityAsConstantName());
     $this->assertSame('file', $error->getFile());
     $this->assertSame(0, $error->getLine());
     $this->assertSame('Fatal error:  message in file on line 0', (string) $error);
 }
示例#3
0
 private static function applyCodeInfo(ThrowableInfo $throwableInfo, \Error $e)
 {
     $filePath = $e->getFile();
     $lineNo = $e->getLine();
     self::findCallPos($e, $filePath, $lineNo);
     if ($filePath !== null) {
         $throwableInfo->addCodeInfo(self::createCodeInfo($filePath, $lineNo));
     }
 }
示例#4
0
 /**
  * New exception.
  *
  * @param Exception $exception        	
  * @param boolean $printError
  *        	show error or not
  * @param boolean $clear
  *        	clear the errorlog
  * @param string $errorFile
  *        	file to save to
  */
 public static function newMessage(\Error $exception)
 {
     $message = $exception->getMessage();
     $code = $exception->getCode();
     $file = $exception->getFile();
     $line = $exception->getLine();
     $trace = $exception->getTraceAsString();
     $trace = str_replace(DB_PASS, '********', $trace);
     $date = date('M d, Y G:iA');
     $logMessage = "<h3>Exception information:</h3>\n\n           <p><strong>Date:</strong> {$date}</p>\n\n           <p><strong>Message:</strong> {$message}</p>\n\n           <p><strong>Code:</strong> {$code}</p>\n\n           <p><strong>File:</strong> {$file}</p>\n\n           <p><strong>Line:</strong> {$line}</p>\n\n           <h3>Stack trace:</h3>\n\n           <pre>{$trace}</pre>\n\n           <hr />\n";
     $errorFile = self::getCurrentErrorLog();
     if (is_file($errorFile) === false) {
         file_put_contents($errorFile, '');
     }
     if (self::$clear) {
         $f = fopen($errorFile, "r+");
         if ($f !== false) {
             ftruncate($f, 0);
             fclose($f);
         }
         $content = null;
     } else {
         $content = file_get_contents($errorFile);
     }
     file_put_contents($errorFile, $logMessage . $content);
     if (self::$printError == true) {
         echo $logMessage;
         exit;
     }
 }
示例#5
0
 protected function FormatErrorMessage(Error $Error)
 {
     return $Error->getTimestamp() . ' [' . $Error->getCode() . '] "' . $Error->getMessage() . '" in file: ' . $Error->getFilepath() . ', line: ' . $Error->getLine() . PHP_EOL . $Error->getRequest();
 }