Skip to content

Commit

Permalink
Fix issue #273 - Log response failures. (#335)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #335

Reviewed By: mengxuanzhangz

Differential Revision: D53145922

Pulled By: stcheng

fbshipit-source-id: d626f56e7df9df9755895af98cf6516fed50bbab
  • Loading branch information
jamespshields authored and facebook-github-bot committed Jan 29, 2024
1 parent 4b976a8 commit f7a3990
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/FacebookAds/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace FacebookAds;

use FacebookAds\Http\Client;
use FacebookAds\Http\Exception\RequestException;
use FacebookAds\Http\RequestInterface;
use FacebookAds\Http\ResponseInterface;
use FacebookAds\Logger\LoggerInterface;
Expand Down Expand Up @@ -147,7 +148,12 @@ public function prepareRequest(
*/
public function executeRequest(RequestInterface $request) {
$this->getLogger()->logRequest('debug', $request);
$response = $request->execute();
try {
$response = $request->execute();
} catch (RequestException $e) {
$this->getLogger()->logResponse('debug', @$e->getResponse());
throw $e;
}
$this->getLogger()->logResponse('debug', $response);

return $response;
Expand Down

0 comments on commit f7a3990

Please sign in to comment.