private static function handleException(Exception $exception) { $errorString = KalturaErrors::INTERNAL_SERVERL_ERROR; if ($exception instanceof WindowsAzure\Common\ServiceException) { $reasons = json_decode($exception->getErrorReason(), true); switch ($reasons['error']) { case 'invalid_client': if (strpos($reasons['error_description'], 'Authentication failed')) { $errorString = KalturaErrors::WAMS_CREDENTIALS_ERROR; } break; } } throw new KalturaAPIException($errorString); }