You are here

protected static function AcquiaLiftAPI::mapBadResponseToExceptionClass in Acquia Lift Connector 7

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

Maps the passed in response code to an exception class to use.

If the response code passed in constitutes a successful response, NULL is returned. If it does not constitute a 400 or 500 error, NULL is returned.

Parameters

$code: The response code to map.

Return value

null|string The exception class to use or NULL.

1 call to AcquiaLiftAPI::mapBadResponseToExceptionClass()
AcquiaLiftAPI::handleBadResponse in includes/acquia_lift.classes.inc
Figures out the correct exception to throw and throws it.

File

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

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

protected static function mapBadResponseToExceptionClass($code) {
  if (self::isSuccessful($code)) {
    return NULL;
  }
  if (self::isClientError($code)) {
    switch ($code) {
      case 404:
        return 'AcquiaLiftNotFoundException';
      case 403:
        return 'AcquiaLiftForbiddenException';
      default:
        return 'AcquiaLiftClientErrorException';
    }
  }
  elseif (self::isServerError($code)) {
    return 'AcquiaLiftServerErrorException';
  }
  return NULL;
}