You are here

function clients_connection_drupal_services_rest_7::handleRestError in Web Service Clients 7.3

Common helper for reacting to an error from a REST call.

Gets the error from the response, logs the error message, and throws an exception, which should be caught by the module making use of the Clients connection API.

Parameters

$response: The REST response data, decoded.

Throws

Exception

2 calls to clients_connection_drupal_services_rest_7::handleRestError()
clients_connection_drupal_services_rest_7::makeRequest in connections/clients_drupal_rest/clients_drupal_rest.inc
Make a REST request.
clients_connection_drupal_services_rest_7::userLogin in connections/clients_drupal_rest/clients_drupal_rest.inc
Log in as the configured user.

File

connections/clients_drupal_rest/clients_drupal_rest.inc, line 89
Contains classes for Client connections handlers.

Class

clients_connection_drupal_services_rest_7
Class for Drupal client connections, REST D7.

Code

function handleRestError($response) {
  if ($response->code != 200) {
    watchdog('clients', 'Error with REST request. Error was code @code with error "@error" and message "@message".', array(
      '@code' => $response->code,
      '@error' => $response->error,
      '@message' => isset($response->status_message) ? $response->status_message : '(no message)',
    ));
    throw new Exception(t("Clients connection error, got message '@message'.", array(
      '@message' => isset($response->status_message) ? $response->status_message : $response->error,
    )), $response->code);
  }
}