Improved error handling
This commit is contained in:
parent
c7bafaf564
commit
69ed0f733d
2
docs
2
docs
|
@ -1 +1 @@
|
||||||
Subproject commit 319f29dbb5d5729e02e246802d7cb5ba7d2c8815
|
Subproject commit dc05dc5cebfcec90ac7851928c522a4d635dbab6
|
|
@ -61,7 +61,7 @@ class Lang
|
||||||
'loading_key' => 'Caricamento della chiave in corso...',
|
'loading_key' => 'Caricamento della chiave in corso...',
|
||||||
'computing_fingerprint' => 'Calcolo del fingerprint in corso...',
|
'computing_fingerprint' => 'Calcolo del fingerprint in corso...',
|
||||||
'rsa_encrypting' => 'Criptando con chiave RSA...',
|
'rsa_encrypting' => 'Criptando con chiave RSA...',
|
||||||
'rpc_tg_error' => 'Telegram ha ritornato un errore RPC: %s (%s), causato da %s:%sTL trace:',
|
'rpc_tg_error' => 'Telegram ha ritornato un errore RPC: %s (%s), causato da %s:%s%sTL trace:',
|
||||||
'v_error' => '506572206661766f726520616767696f726e612071756573746120696e7374616c6c617a696f6e65206469204d6164656c696e6550726f746f20636f6e206769742070756c6c206520636f6d706f73657220757064617465',
|
'v_error' => '506572206661766f726520616767696f726e612071756573746120696e7374616c6c617a696f6e65206469204d6164656c696e6550726f746f20636f6e206769742070756c6c206520636f6d706f73657220757064617465',
|
||||||
'v_tgerror' => '506572206661766f726520616767696f726e61207068702d6c69627467766f6970',
|
'v_tgerror' => '506572206661766f726520616767696f726e61207068702d6c69627467766f6970',
|
||||||
'no_mode_specified' => 'Nessuna modalità di logging è stata specificata!',
|
'no_mode_specified' => 'Nessuna modalità di logging è stata specificata!',
|
||||||
|
@ -208,7 +208,7 @@ class Lang
|
||||||
'loading_key' => 'Loading key...',
|
'loading_key' => 'Loading key...',
|
||||||
'computing_fingerprint' => 'Computing fingerprint...',
|
'computing_fingerprint' => 'Computing fingerprint...',
|
||||||
'rsa_encrypting' => 'Encrypting with rsa key...',
|
'rsa_encrypting' => 'Encrypting with rsa key...',
|
||||||
'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:',
|
'rpc_tg_error' => 'Telegram ha ritornato un errore RPC: %s (%s), causato da %s:%s%sTL trace:',
|
||||||
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
|
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
|
||||||
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
|
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
|
||||||
'no_mode_specified' => 'No mode was specified!',
|
'no_mode_specified' => 'No mode was specified!',
|
||||||
|
@ -4955,7 +4955,7 @@ class Lang
|
||||||
'loading_key' => 'Loading key...',
|
'loading_key' => 'Loading key...',
|
||||||
'computing_fingerprint' => 'Computing fingerprint...',
|
'computing_fingerprint' => 'Computing fingerprint...',
|
||||||
'rsa_encrypting' => 'Encrypting with rsa key...',
|
'rsa_encrypting' => 'Encrypting with rsa key...',
|
||||||
'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:',
|
'rpc_tg_error' => 'Telegram ha ritornato un errore RPC: %s (%s), causato da %s:%s%sTL trace:',
|
||||||
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
|
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
|
||||||
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
|
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
|
||||||
'no_mode_specified' => 'No mode was specified!',
|
'no_mode_specified' => 'No mode was specified!',
|
||||||
|
|
|
@ -235,11 +235,13 @@ trait PeerHandler
|
||||||
case 'peerUser':
|
case 'peerUser':
|
||||||
return $id['user_id'];
|
return $id['user_id'];
|
||||||
case 'chat':
|
case 'chat':
|
||||||
|
case 'chatForbidden':
|
||||||
case 'chatFull':
|
case 'chatFull':
|
||||||
return -$id['id'];
|
return -$id['id'];
|
||||||
case 'inputPeerChat':
|
case 'inputPeerChat':
|
||||||
case 'peerChat':
|
case 'peerChat':
|
||||||
return -$id['chat_id'];
|
return -$id['chat_id'];
|
||||||
|
case 'channelForbidden':
|
||||||
case 'channel':
|
case 'channel':
|
||||||
case 'channelFull':
|
case 'channelFull':
|
||||||
return $this->to_supergroup($id['id']);
|
return $this->to_supergroup($id['id']);
|
||||||
|
@ -302,9 +304,6 @@ trait PeerHandler
|
||||||
case 'updateEditChannelMessage':
|
case 'updateEditChannelMessage':
|
||||||
case 'updateNewEncryptedMessage':
|
case 'updateNewEncryptedMessage':
|
||||||
return $this->get_id($id['message']);
|
return $this->get_id($id['message']);
|
||||||
case 'chatForbidden':
|
|
||||||
case 'channelForbidden':
|
|
||||||
throw new \danog\MadelineProto\RPCErrorException('CHAT_FORBIDDEN');
|
|
||||||
default:
|
default:
|
||||||
throw new \danog\MadelineProto\Exception('Invalid constructor given '.var_export($id, true));
|
throw new \danog\MadelineProto\Exception('Invalid constructor given '.var_export($id, true));
|
||||||
}
|
}
|
||||||
|
@ -508,7 +507,6 @@ trait PeerHandler
|
||||||
break;
|
break;
|
||||||
case 'channelForbidden':
|
case 'channelForbidden':
|
||||||
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
||||||
throw new \danog\MadelineProto\RPCErrorException('CHAT_FORBIDDEN');
|
|
||||||
default:
|
default:
|
||||||
throw new \danog\MadelineProto\Exception('Invalid constructor given '.var_export($constructor, true));
|
throw new \danog\MadelineProto\Exception('Invalid constructor given '.var_export($constructor, true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,7 +370,7 @@ trait ResponseHandler
|
||||||
}
|
}
|
||||||
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : ''));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
case 303:
|
case 303:
|
||||||
|
@ -420,7 +420,7 @@ trait ResponseHandler
|
||||||
$this->callFork((function () use ($datacenter, &$request, &$response) {
|
$this->callFork((function () use ($datacenter, &$request, &$response) {
|
||||||
yield $this->init_authorization_async();
|
yield $this->init_authorization_async();
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : ''));
|
||||||
})());
|
})());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -432,7 +432,7 @@ trait ResponseHandler
|
||||||
$this->callFork((function () use ($datacenter, &$request, &$response) {
|
$this->callFork((function () use ($datacenter, &$request, &$response) {
|
||||||
yield $this->init_authorization_async();
|
yield $this->init_authorization_async();
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : ''));
|
||||||
})());
|
})());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -467,7 +467,7 @@ trait ResponseHandler
|
||||||
$this->callFork((function () use ($datacenter, &$request, &$response) {
|
$this->callFork((function () use ($datacenter, &$request, &$response) {
|
||||||
yield $this->init_authorization_async();
|
yield $this->init_authorization_async();
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : ''));
|
||||||
})());
|
})());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -492,7 +492,7 @@ trait ResponseHandler
|
||||||
}
|
}
|
||||||
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : ''));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
case 420:
|
case 420:
|
||||||
|
@ -511,7 +511,7 @@ trait ResponseHandler
|
||||||
default:
|
default:
|
||||||
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : ''));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ trait ResponseHandler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException('Received bad_msg_notification: '.self::BAD_MSG_ERROR_CODES[$response['error_code']], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException('Received bad_msg_notification: '.self::BAD_MSG_ERROR_CODES[$response['error_code']], $response['error_code'], isset($request['_']) ? $request['_'] : ''));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class RPCErrorException extends \Exception
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$result = sprintf(\danog\MadelineProto\Lang::$current_lang['rpc_tg_error'], $this->getMess(), $this->rpc, $this->file, $this->line.PHP_EOL.PHP_EOL).PHP_EOL.\danog\MadelineProto\Magic::$revision.PHP_EOL.$this->getTLTrace().PHP_EOL;
|
$result = sprintf(\danog\MadelineProto\Lang::$current_lang['rpc_tg_error'], $this->getMess(), $this->rpc, $this->file, $this->line.PHP_EOL, \danog\MadelineProto\Magic::$revision.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
|
||||||
if (php_sapi_name() !== 'cli') {
|
if (php_sapi_name() !== 'cli') {
|
||||||
$result = str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
$result = str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class RPCErrorException extends \Exception
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct($message = null, $code = 0, Exception $previous = null)
|
public function __construct($message = null, $code = 0, $caller = '', Exception $previous = null)
|
||||||
{
|
{
|
||||||
$this->rpc = $message;
|
$this->rpc = $message;
|
||||||
switch ($message) {
|
switch ($message) {
|
||||||
|
@ -178,7 +178,7 @@ class RPCErrorException extends \Exception
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
$this->prettify_tl();
|
$this->prettify_tl($caller);
|
||||||
$additional = [];
|
$additional = [];
|
||||||
foreach ($this->getTrace() as $level) {
|
foreach ($this->getTrace() as $level) {
|
||||||
if (isset($level['function']) && $level['function'] === 'method_call') {
|
if (isset($level['function']) && $level['function'] === 'method_call') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user