Commit 97570291 by Klimov Paul

`yii\authclient\InvalidResponseException` added

parent a1a9d9a3
......@@ -201,7 +201,7 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
throw new Exception('Curl error requesting "' . $url . '": #' . $errorNumber . ' - ' . $errorMessage);
}
if ($responseHeaders['http_code'] != 200) {
throw new Exception('Request failed with code: ' . $responseHeaders['http_code'] . ', message: ' . $response);
throw new InvalidResponseException($responseHeaders, $response, 'Request failed with code: ' . $responseHeaders['http_code'] . ', message: ' . $response);
}
return $this->processResponse($response, $this->determineContentTypeByHeaders($responseHeaders));
......
......@@ -7,6 +7,7 @@ Yii Framework 2 authclient extension Change Log
- Bug #3633: OpenId return URL comparison advanced to prevent url encode problem (klimov-paul)
- Enh #3416: VKontakte OAuth support added (klimov-paul)
- Enh #4076: Request HTTP headers argument added to `yii\authclient\BaseOAuth::api()` method (klimov-paul)
- Enh #4134: `yii\authclient\InvalidResponseException` added for tracking invalid remote server response (klimov-paul)
- Enh #4139: User attributes requesting at GoogleOAuth switched to Google+ API (klimov-paul)
......
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\authclient;
use yii\base\Exception;
/**
* InvalidResponseException represents an exception caused by invalid remote server response.
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
*/
class InvalidResponseException extends Exception
{
/**
* @var array response headers.
*/
public $responseHeaders = [];
/**
* @var string response body.
*/
public $responseBody = '';
/**
* Constructor.
* @param array $responseHeaders response headers
* @param string $responseBody response body
* @param string $message error message
* @param integer $code error code
* @param \Exception $previous The previous exception used for the exception chaining.
* @internal param int $status HTTP status code, such as 404, 500, etc.
*/
public function __construct($responseHeaders, $responseBody, $message = null, $code = 0, \Exception $previous = null)
{
$this->responseBody = $responseBody;
$this->responseHeaders = $responseHeaders;
parent::__construct($message, $code, $previous);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment