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

Missing error handling of no response #101

Open
stanleynguyen opened this issue Sep 30, 2020 · 2 comments
Open

Missing error handling of no response #101

stanleynguyen opened this issue Sep 30, 2020 · 2 comments

Comments

@stanleynguyen
Copy link
Contributor

$response = $e->getResponse();
$rbody = json_decode($response->getBody()->getContents(), true);
$rcode = $response->getStatusCode();
$rheader = $response->getHeaders();
self::_handleAPIError(
array('body' => $rbody,
'code' => $rcode,
'header' => $rheader)
);

sometimes give this error Call to a member function getBody() on null on line 133 as the response is not always there

@aqin96
Copy link

aqin96 commented Jan 3, 2021

Saya kesulitan menangkap error message pada saat request pembuatan transaksi OVO. Saya menggunakan library xendit-php. Apa yang perlu saya lakukan untuk mendapatkan pesan error setelah menuliskan kode berikut :
$createOvo = \Xendit\EWallets::create($ovoParams);

@CorbaDigitpaint
Copy link
Contributor

CorbaDigitpaint commented Feb 2, 2021

I just stumbled upon a similar issue here.. I have implemented a custom HTTPClient for Xendit to support calls using a proxy server. By coincidence, our proxy server was rejecting requests and returning HTTP (header) Code 407 and no body in the HTTP response. This is the uncaught error:

[Tue Feb 02 12:29:54.223559 2021] [php7:error] [pid 90687] [client 10.22.0.15:33294] PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Xendit\\Exceptions\\ApiException::__construct(), 1 passed in <masked>/vendor/xendit/xendit-php/src/Exceptions/ApiException.php on line 50 and exactly 3 expected in <masked>/vendor/xendit/xendit-php/src/Exceptions/ApiException.php:47
Stack trace:
#0 <masked>/vendor/xendit/xendit-php/src/Exceptions/ApiException.php(50): Xendit\\Exceptions\\ApiException->__construct('Unknown Xendit\\\\...')
#1 <masked>/vendor/xendit/xendit-php/src/HttpClient/GuzzleClient.php(167): Xendit\\Exceptions\\ApiException->__construct(NULL, '407', NULL)

This is the $response in GuzzleClient _handleApiError():

    [body] => 
    [code] => 407
    [header] => Array
        (
[Server] => Array
    (
        [0] => squid/3.5.20
    )

[Mime-Version] => Array
    (
        [0] => 1.0
    )

[Date] => Array
    (
        [0] => Tue, 02 Feb 2021 13:41:04 GMT
    )

[Content-Type] => Array
    (
        [0] => text/html;charset=utf-8
    )

[Content-Length] => Array
    (
        [0] => 3523
    )

[X-Squid-Error] => Array
    (
        [0] => ERR_CACHE_ACCESS_DENIED 0
    )

[Vary] => Array
    (
        [0] => Accept-Language
    )

[Content-Language] => Array
    (
        [0] => en
    )

[Proxy-Authenticate] => Array
    (
        [0] => Basic realm="Squid proxy-caching web server"
    )

[X-Cache] => Array
    (
        [0] => MISS from <proxyserver.com>
    )

[X-Cache-Lookup] => Array
    (
        [0] => NONE from <proxyserver.com>:<port>>
    )

[Via] => Array
    (
        [0] => 1.1 <proxyserver.com> (squid/3.5.20)

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

3 participants