1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 08:51:15 +01:00

Added additional error handling

This commit is contained in:
Daniil Gentili 2016-11-29 13:25:11 +00:00
parent 885520c96a
commit c62d8cc069
2 changed files with 20 additions and 0 deletions

Binary file not shown.

View File

@ -42,6 +42,26 @@ class CallHandler extends AuthKeyHandler
throw new \danog\MadelineProto\Exception('I had to switch to datacenter '.$dc);
break;
case 401:
switch ($response['error_message']) {
case "AUTH_KEY_UNREGISTERED":
case "AUTH_KEY_INVALID":
unset($this->datacenter->temp_auth_key);
unset($this->datacenter->auth_key);
$this->init_authorization();
case "USER_DEACTIVATED":
case "SESSION_REVOKED":
case "SESSION_EXPIRED":
$this->datacenter->authorized = false;
$this->datacenter->authorization = null;
throw new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']);
break;
}
case 420:
$seconds = preg_replace('/[^0-9]+/', '', $response['error_message']);
\danog\MadelineProto\Logger::log('Flood, waiting '.$seconds.' seconds...');
sleep($seconds);
throw new \danog\MadelineProto\Exception('Re-executing query...');
default:
throw new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']);
break;