type = \get_class($exception); $this->parent = $exception instanceof \Error ? self::PARENT_ERROR : self::PARENT_EXCEPTION; $this->message = $exception->getMessage(); $this->code = $exception->getCode(); $this->trace = $exception->getTraceAsString(); } public function promise(): Promise { switch ($this->parent) { case self::PARENT_ERROR: $exception = new TaskError( $this->type, sprintf( 'Uncaught Error in worker of type "%s" with message "%s" and code "%s"', $this->type, $this->message, $this->code ), $this->trace ); break; default: $exception = new TaskException( $this->type, sprintf( 'Uncaught Exception in worker of type "%s" with message "%s" and code "%s"', $this->type, $this->message, $this->code ), $this->trace ); } return new Failure($exception); } }