1

I am using guzzle to call web service .If there is any error i get white screen with error. 'GuzzleHttp\Exception\ClientException: Client error'

My code is as follow: try { $response = $this->httpClient->post($endPoint, [ 'verify' => FALSE, 'body' => Json::encode($data), 'headers' => [ 'Auth-Token' => $token, 'Content-Type' => 'application/json', ], ]) } catch (RequestException $e) { watchdog_exception('message', $e->getMessage()); }

if i add 'http_errors' => false as option in post request i don't get white screen. Is there any other way of implementation that i don't get white screen with error if try block fails. The desired feature is if there is a error in calling web service the default page should reload.

closed as off-topic by mradcliffe, Adrian Cid Almaguer, Pierre.Vriens, kiamlaluno Jun 14 '17 at 11:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on programming, PHP, SQL, etc. that do not relate directly to Drupal are off-topic here, but can be asked on Stack Overflow." – mradcliffe, Adrian Cid Almaguer, Pierre.Vriens, kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • @mradcliffe The solution on stackoverflow.com/a/30957410/5334703 is not working – Aditya Joshi Jun 14 '17 at 17:00
  • Your comment doesn't really help. You may not be implementing guzzle or exception handling correctly in your code per guzzle documentation. – mradcliffe Jun 15 '17 at 17:51
  • It finally work! i was missing name space "use GuzzleHttp\Exception\RequestException;" – Aditya Joshi Jun 16 '17 at 20:53

Browse other questions tagged or ask your own question.