Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendRequest return null, new Response($res); will report error #57

Open
stingbo opened this issue Sep 2, 2024 · 1 comment
Open

sendRequest return null, new Response($res); will report error #57

stingbo opened this issue Sep 2, 2024 · 1 comment

Comments

@stingbo
Copy link

stingbo commented Sep 2, 2024

  public function execute(RequestInterface $request): Response
    {
        $res = $this->transport->sendRequest($request);
        $statusCode = $res->getStatusCode();
        if ($statusCode >= 400 && $statusCode < 500) {
            $errorResponse = new Response($res);
            throw (new InvalidArgumentException(
                $errorResponse['status']['error'] ?? 'Invalid Argument Exception',
                $statusCode)
            )->setResponse($errorResponse);
        } elseif ($statusCode >= 500) {
            $errorResponse = new Response($res);
            throw (new ServerException(
                $errorResponse['status']['error'] ?? '500 Interval Service Error',
                $statusCode)
            )->setResponse($errorResponse);
        }

        return new Response($res);
    }

if sendRequest return null, new Response($res); will report error

@hkulekci
Copy link
Owner

hkulekci commented Sep 7, 2024

Hello @stingbo, thanks for reporting. I will check soon! Please don't hesitate to create another issue if you face another problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants