mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 04:59:00 +01:00
Cleanup error generation
This commit is contained in:
parent
238f49b259
commit
0750b226f8
@ -19,6 +19,7 @@
|
|||||||
<directory name="src" />
|
<directory name="src" />
|
||||||
<ignoreFiles>
|
<ignoreFiles>
|
||||||
<directory name="vendor" />
|
<directory name="vendor" />
|
||||||
|
<directory name="src/RPCError" />
|
||||||
<file name="src/TL/TLParser.php" />
|
<file name="src/TL/TLParser.php" />
|
||||||
<file name="src/InternalDoc.php" />
|
<file name="src/InternalDoc.php" />
|
||||||
<file name="src/TL/SecretTLParser.php" />
|
<file name="src/TL/SecretTLParser.php" />
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?php declare(strict_types=1);
|
|
||||||
/**
|
|
||||||
* FileReference*Error error.
|
|
||||||
*
|
|
||||||
* This file is part of MadelineProto.
|
|
||||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU Affero General Public License for more details.
|
|
||||||
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @copyright 2016-2024 Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
|
||||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace danog\MadelineProto\RPCError;
|
|
||||||
|
|
||||||
use danog\MadelineProto\RPCErrorException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The file reference expired, it [must be refreshed](https://core.telegram.org/api/file_reference).
|
|
||||||
*/
|
|
||||||
final class FileReference*Error extends RPCErrorException
|
|
||||||
{
|
|
||||||
public function __construct(string $caller, ?\Exception $previous = null) {
|
|
||||||
parent::__construct('FILE_REFERENCE_*', 400, $caller, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
@ -216,7 +216,7 @@ class RPCErrorException extends \Exception
|
|||||||
?\Exception $previous = null
|
?\Exception $previous = null
|
||||||
): self {
|
): self {
|
||||||
// Start match
|
// Start match
|
||||||
match ($rpc) {
|
return match ($rpc) {
|
||||||
'ABOUT_TOO_LONG' => new \danog\MadelineProto\RPCError\AboutTooLongError($caller, $previous),
|
'ABOUT_TOO_LONG' => new \danog\MadelineProto\RPCError\AboutTooLongError($caller, $previous),
|
||||||
'ACCESS_TOKEN_EXPIRED' => new \danog\MadelineProto\RPCError\AccessTokenExpiredError($caller, $previous),
|
'ACCESS_TOKEN_EXPIRED' => new \danog\MadelineProto\RPCError\AccessTokenExpiredError($caller, $previous),
|
||||||
'ACCESS_TOKEN_INVALID' => new \danog\MadelineProto\RPCError\AccessTokenInvalidError($caller, $previous),
|
'ACCESS_TOKEN_INVALID' => new \danog\MadelineProto\RPCError\AccessTokenInvalidError($caller, $previous),
|
||||||
|
@ -58,7 +58,7 @@ trait PrettyException
|
|||||||
* @param string $init Method name
|
* @param string $init Method name
|
||||||
* @param array $trace Async trace
|
* @param array $trace Async trace
|
||||||
*/
|
*/
|
||||||
public function prettifyTL(string $init, ?array $trace = null): void
|
public function prettifyTL(string $init = '', ?array $trace = null): void
|
||||||
{
|
{
|
||||||
$this->method = $init;
|
$this->method = $init;
|
||||||
$previous_trace = $this->tlTrace;
|
$previous_trace = $this->tlTrace;
|
||||||
|
@ -41,6 +41,9 @@ chdir($d=__DIR__.'/..');
|
|||||||
|
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
`rm -r src/RPCError/*`;
|
||||||
|
`git checkout src/RPCError/FloodWaitError.php`;
|
||||||
|
|
||||||
$map = [];
|
$map = [];
|
||||||
|
|
||||||
$year = date('Y');
|
$year = date('Y');
|
||||||
@ -98,7 +101,7 @@ foreach ($errors['result'] as $code => $sub) {
|
|||||||
|
|
||||||
$err = file_get_contents('src/RPCErrorException.php');
|
$err = file_get_contents('src/RPCErrorException.php');
|
||||||
$err = preg_replace_callback('|// Start match.*// End match|sim', static function ($matches) use ($map) {
|
$err = preg_replace_callback('|// Start match.*// End match|sim', static function ($matches) use ($map) {
|
||||||
$data = "match (\$rpc) {\n";
|
$data = "return match (\$rpc) {\n";
|
||||||
foreach ($map as $err => [$human, $code, $class]) {
|
foreach ($map as $err => [$human, $code, $class]) {
|
||||||
$data .= "$err => new $class(\$caller, \$previous),\n";
|
$data .= "$err => new $class(\$caller, \$previous),\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user