seatplus/esi-client

View on GitHub
src/Exceptions/RequestFailedException.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Seatplus\EsiClient\Exceptions;

use Seatplus\EsiClient\DataTransferObjects\EsiResponse;

class RequestFailedException extends \Exception
{
    public function __construct(private readonly \Exception $original_exception, private readonly EsiResponse $esiResponse)
    {
        parent::__construct(
            $this->getErrorMessage(),
            $this->getOriginalException()->getCode(),
            $this->getOriginalException()->getPrevious()
        );
    }

    public function getEsiResponse(): EsiResponse
    {
        return $this->esiResponse;
    }

    public function getOriginalException(): \Exception
    {
        return $this->original_exception;
    }

    public function getErrorMessage(): string
    {
        return $this->getEsiResponse()->getErrorMessage();
    }
}