Skip to content

Commit

Permalink
Добавлен метод для получения последней ошибки
Browse files Browse the repository at this point in the history
  • Loading branch information
StacoNiK committed Nov 17, 2016
1 parent 06106a2 commit 72b6a42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/VKApi/VkApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class VkApi
public static $version = "5.53";
protected static $captcha_handler;
protected static $is_captcha_handler = false;
protected static $last_error;

protected $access_token = false;

Expand Down Expand Up @@ -32,6 +33,16 @@ public static function getCaptchaHandler()
return false;
}

public static function getLastError()
{
return self::$last_error;
}

public static function setLastError($error)
{
self::$last_error = $error;
}

public function __construct($token = null)
{
if ($token instanceof VkAccessToken) {
Expand Down
4 changes: 3 additions & 1 deletion src/VKApi/VkError.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ class VkError
{
public $error_code = 0;
public $error_msg = "";
public $request_params = array();
public $request_params = [];
public $error_array = [];

public function __construct($jsonArray)
{
$this->error_code = $jsonArray["error_code"];
$this->error_msg = $jsonArray["error_msg"];
$this->request_params = $jsonArray["request_params"];
$this->error_array = $jsonArray;
}
}
1 change: 1 addition & 0 deletions src/VKApi/VkRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function execute($depth = 0)
}
}
$vkError = new VkError($jsonArray['error']);
VkApi::setLastError($vkError);
$vkResult->is_error = true;
$vkResult->error = $vkError;
if ($this->vk_error_listener) {
Expand Down

0 comments on commit 72b6a42

Please sign in to comment.