From 1a3286cadcadfba1ebfd3aaa535e41a87b9cba28 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 23 Oct 2017 22:42:09 +0200 Subject: [PATCH] Request exception catch --- proxy.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/proxy.php b/proxy.php index b24a579..60d00d0 100644 --- a/proxy.php +++ b/proxy.php @@ -1,9 +1,10 @@ getServerParams()['PATH_INFO'], '/') - ); + $serverParams = $request->getServerParams(); + $uri = isset($serverParams['PATH_INFO']) ? ltrim($serverParams['PATH_INFO']) : ''; + + $url = sprintf('https://bittrex.com/api/v1.1/%s', $uri); unset($headers['host']); @@ -43,10 +44,14 @@ function doRequest(ServerRequest $request, Client $client) ); } -$apiResponse = doRequest( - ServerRequestFactory::fromGlobals(), - new Client() -); +try { + $apiResponse = doRequest( + ServerRequestFactory::fromGlobals(), + new Client() + ); +} catch (ClientException $e) { + $apiResponse = $e->getResponse(); +} send(new Response( $apiResponse->getBody(),