37 private ThreadSafeArray $trace;
44 private string $message,
48 private string $threadName
50 $this->trace = ThreadSafeArray::fromArray($trace);
53 public static function fromThrowable(\Throwable $e,
string $threadName) : self{
54 return new self(get_class($e), $e->getMessage(), $e->getFile(), $e->getLine(),
Utils::printableTraceWithMetadata($e->
getTrace()), $threadName);
63 }
catch(\InvalidArgumentException){
64 $class =
"Unknown error type (" . $info[
"type"] .
")";
66 return new self($class, $info[
"message"], $info[
"file"], $info[
"line"], Utils::printableTraceWithMetadata(Utils::currentTrace()), $threadName);
69 public function getType() : string{ return $this->type; }
71 public function getMessage() : string{ return $this->message; }
73 public function getFile() : string{ return $this->file; }
75 public function getLine() : int{ return $this->line; }
81 return (array) $this->trace;
84 public function getThreadName() : string{ return $this->threadName; }
86 public function makePrettyMessage() : string{
87 return sprintf(
"%s: \"%s\" in \"%s\" on line %d", $this->type ??
"Fatal error", $this->message,
Filesystem::cleanPath($this->file), $this->line);