/**
  * Handle an error message
  *
  * @param int $type
  * @param string $message
  * @param string $file
  * @param int $line
  * @param array|null $context
  * @return bool
  */
 public function handleError(int $type, string $message, string $file, int $line, array $context = null)
 {
     if (error_reporting() === 0) {
         return false;
     }
     if ($context) {
     }
     if (in_array($type, [2, 8, 512, 1024, 2048, 8192, 16384])) {
         $ignore = $type === 8 ? $this->ignoreNotice : false;
         if (!$ignore) {
             $error = ["type" => $this->errorType($type), "message" => $message, "file" => $file, "line" => $line];
             $parser = Parser::getInstance();
             $error["formatted"] = $parser->parse($this->format, $error);
             if ($this->method != Kernel::ERRORS_PUBLISH) {
                 $this->logged[] = $error;
             }
             if ($this->method != Kernel::ERRORS_COLLECT) {
                 print $error["formatted"] . "<br>" . Kernel::EOL;
             }
         }
     } else {
         try {
             throw new \RuntimeException($message, $type);
         } catch (\RuntimeException $e) {
             (new Kernel\ErrorHandler\Screen($this->kernel))->send($e);
         }
     }
     return true;
 }
Example #2
0
 /**
  * @param string|null $pattern
  * @return string
  */
 public function getParsed(string $pattern = null) : string
 {
     if (empty($pattern)) {
         // Set default pattern
         $pattern = "%classMethod%: [#%code%] %message% in %file|basename%:%line%";
     }
     $parser = \Comely\IO\Toolkit\Parser::getInstance();
     return $parser->parse($pattern, ["classMethod" => $this->method, "code" => $this->code, "message" => $this->getHtmlEncoded(), "file" => $this->file, "line" => $this->line]);
 }