You are here

public function AcquiaLiftAPI::handleBadResponse in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 includes/AcquiaLiftAPI.inc \AcquiaLiftAPI::handleBadResponse()

Figures out the correct exception to throw and throws it.

Parameters

$response_code: The response code, e.g. 404.

$fail_msg: The message to use for the exception, and for logging if $log_failure it TRUE.

array $vars: Variables to pass to the message.

bool $log_failure: Whether failures should be logged or not

28 calls to AcquiaLiftAPI::handleBadResponse()
AcquiaLiftAPI::deleteAgent in includes/acquia_lift.classes.inc
Deletes an agent.
AcquiaLiftAPI::deleteAutoTargetingRule in includes/acquia_lift.classes.inc
Deletes the auto targeting rule for the specified agent.
AcquiaLiftAPI::deleteDecision in includes/acquia_lift.classes.inc
Deletes a decision from an agent.
AcquiaLiftAPI::deleteGoal in includes/acquia_lift.classes.inc
Deletes a goal from an agent.
AcquiaLiftAPI::deletePoint in includes/acquia_lift.classes.inc
Deletes an entire decision point from an agent.

... See full list

File

includes/acquia_lift.classes.inc, line 506
Provides an agent type for Acquia Lift

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public function handleBadResponse($response_code, $fail_msg, $vars = array(), $log_failure = TRUE) {
  if ($exception_class = self::mapBadResponseToExceptionClass($response_code)) {
    if ($log_failure) {
      $this
        ->logger()
        ->log(PersonalizeLogLevel::ERROR, $fail_msg, $vars);
    }
    throw new $exception_class(t($fail_msg, $vars));
  }
  if (self::isSuccessful($response_code)) {

    // If the response wasn't actually bad but we still got here somehow, just
    // log a warning and return.
    if ($log_failure) {
      $this
        ->logger()
        ->log(PersonalizeLogLevel::WARNING, $fail_msg, $vars);
    }
    return;
  }

  // Otherwise throw a generic exception.
  throw new AcquiaLiftException($fail_msg);
}