error = $error; } /** * Get the error object. * * @return \Throwable * * @since 2.0.0 */ public function getError(): \Throwable { return $this->error; } /** * Gets the exit code. * * @return integer * * @since 2.0.0 */ public function getExitCode(): int { if ($this->exitCode !== null) { return $this->exitCode; } return \is_int($this->error->getCode()) && $this->error->getCode() !== 0 ? $this->error->getCode() : 1; } /** * Set the error object. * * @param \Throwable $error The error object to set to the event. * * @return void * * @since 2.0.0 */ public function setError(\Throwable $error): void { $this->error = $error; } /** * Sets the exit code. * * @param integer $exitCode The command exit code. * * @return void * * @since 2.0.0 */ public function setExitCode(int $exitCode): void { $this->exitCode = $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); } }