/** * @see \Components\Runtime_Exception_Transformable::toArray() toArray */ public function toArray($includeStackTrace_ = false, $stackTraceAsArray_ = false) { $asArray = ['id' => \math\hasho_md5($this), 'type' => get_class($this), 'code' => $this->getCode(), 'namespace' => $this->getNamespace(), 'message' => $this->getMessage(), 'file' => $this->getFile(), 'line' => $this->getLine()]; if ($includeStackTrace_ && $stackTraceAsArray_) { $asArray['stack'] = exception_stacktrace_as_array($this); } else { if ($includeStackTrace_) { $asArray['stack'] = $this->getTraceAsString(); } } return $asArray; }
/** * Convert given exception to an array of scalar values. * * @param \Exception $e_ * @param bool $includeStackTrace_ * @param bool $stackTraceAsArray_ * * @return scalar[][] */ function exception_as_array(\Exception $e_, $includeStackTrace_ = false, $stackTraceAsArray_ = false) { if ($e_ instanceof \Components\Runtime_Exception_Transformable) { return $e_->toArray($includeStackTrace_, $stackTraceAsArray_); } $type = Components\Type::of($e_); $exceptionAsArray = ['id' => \math\hasho_md5($e_), 'type' => $type->name(), 'code' => $e_->getCode(), 'namespace' => $type->ns()->name(), 'message' => $e_->getMessage(), 'file' => $e_->getFile(), 'line' => $e_->getLine()]; if ($includeStackTrace_ && $stackTraceAsArray_) { $exceptionAsArray['stack'] = exception_stacktrace_as_array($e_); } else { if ($includeStackTrace_) { $exceptionAsArray['stack'] = $e_->getTraceAsString(); } } return $exceptionAsArray; }