Skip to content

Commit

Permalink
Add classes for all RPC errors
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jun 15, 2024
1 parent 7595fbf commit 1a60bfa
Show file tree
Hide file tree
Showing 514 changed files with 15,817 additions and 28 deletions.
3 changes: 2 additions & 1 deletion langs/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,6 @@
"translate_madelineproto_web": "MadelineProto pu&ograve; essere tradotto nella tua lingua (stato attuale della traduzione: %d%%), cliccate <a href=\"https://weblate.madelineproto.xyz\" target=\"_blank\">qui per contribuire alla traduzione!</a>",
"translate_madelineproto_cli": "MadelineProto può essere tradotto nella tua lingua (stato attuale della traduzione: %d%%), vai su https://weblate.madelineproto.xyz per contribuire alla traduzione!",
"windows_warning": "Per utenti Windows: per favore passate a Linux se questo passaggio fallisce. Per continuare ad usare Windows, potrebbe essere necessario modificare le impostazioni del firewall per permettere a tutti i processi PHP di creare socket (100% è più facile passare a Linux, su Linux MadelineProto funziona direttamente senza alcuna modifica richiesta)",
"could_not_connect_to_MadelineProto": "Non è stato possibile collegarsi a MadelineProto, per favore abilitare la funzione proc_open e rimuovere ogni limitazione open_basedir o disabilitare le rewrite lato server per fixare! Se l'avete già fatto, assicuratevi che la versione PHP CLI è la stessa versione di PHP web (apache/php-fpm) (stessa versione, estensioni, eccetera) e controllate il file MadelineProto.log per più informazioni sull'errore che ha impedito l'avvio del server IPC."
"could_not_connect_to_MadelineProto": "Non è stato possibile collegarsi a MadelineProto, per favore abilitare la funzione proc_open e rimuovere ogni limitazione open_basedir o disabilitare le rewrite lato server per fixare! Se l'avete già fatto, assicuratevi che la versione PHP CLI è la stessa versione di PHP web (apache/php-fpm) (stessa versione, estensioni, eccetera) e controllate il file MadelineProto.log per più informazioni sull'errore che ha impedito l'avvio del server IPC.",
"baseDirLimitation": "È presente una limitazione basedir: questo può impattare negativamente sulle performance e causare vari problemi, si prega di disabilitare le limitazioni basedir se possibile!"
}
4 changes: 2 additions & 2 deletions src/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Lang
'fr' => 36,
'de' => 0,
'he' => 74,
'it' => 99,
'it' => 100,
'ckb' => 74,
'fa' => 100,
'ru' => 53,
Expand Down Expand Up @@ -1083,7 +1083,7 @@ final class Lang
'apiParamsError' => 'Non hai fornito tutti i parametri richiesti!',
'api_not_set' => 'Devi specificare una chiave ed un ID API, ottienili su https://my.telegram.org',
'array_invalid' => 'Il valore fornito non è un array',
'baseDirLimitation' => 'A basedir limitation is configured: this can impact performance and cause some issues, please disable it if possible!',
'baseDirLimitation' => 'È presente una limitazione basedir: questo può impattare negativamente sulle performance e causare vari problemi, si prega di disabilitare le limitazioni basedir se possibile!',
'bool_error' => 'Non sono riuscito ad estrarre un booleano',
'botAlreadyRunning' => 'Il bot è già in esecuzione!',
'botapi_conversion_error' => 'Non sono risucito a convertire %s in un oggetto bot API',
Expand Down
4 changes: 2 additions & 2 deletions src/Loop/Connection/ReadLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
use danog\MadelineProto\MTProto\MTProtoIncomingMessage;
use danog\MadelineProto\MTProtoTools\Crypt;
use danog\MadelineProto\NothingInTheSocketException;
use danog\MadelineProto\RPCErrorException;
use danog\MadelineProto\SecurityException;
use danog\MadelineProto\Tools;
use danog\MadelineProto\TransportError;
use Error;
use Revolt\EventLoop;

Expand Down Expand Up @@ -109,7 +109,7 @@ protected function loop(): ?float
$this->connection->reconnect();
} else {
$this->connection->reconnect();
throw new RPCErrorException((string) $error, $error);
throw new TransportError($error);
}
});
$this->API->logger("Stopping $this due to $error...", Logger::ERROR);
Expand Down
31 changes: 31 additions & 0 deletions src/RPCError/AboutTooLongError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AboutTooLongError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto\RPCError;

use danog\MadelineProto\RPCErrorException;

/**
* About string too long.
*/
final class AboutTooLongError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ABOUT_TOO_LONG', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AccessTokenExpiredError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AccessTokenExpiredError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto\RPCError;

use danog\MadelineProto\RPCErrorException;

/**
* Access token expired.
*/
final class AccessTokenExpiredError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ACCESS_TOKEN_EXPIRED', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AccessTokenInvalidError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AccessTokenInvalidError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto\RPCError;

use danog\MadelineProto\RPCErrorException;

/**
* Access token invalid.
*/
final class AccessTokenInvalidError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ACCESS_TOKEN_INVALID', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AddressInvalidError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AddressInvalidError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @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 specified geopoint address is invalid.
*/
final class AddressInvalidError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ADDRESS_INVALID', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AdminIdInvalidError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AdminIdInvalidError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @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 specified admin ID is invalid.
*/
final class AdminIdInvalidError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ADMIN_ID_INVALID', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AdminRankEmojiNotAllowedError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AdminRankEmojiNotAllowedError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto\RPCError;

use danog\MadelineProto\RPCErrorException;

/**
* An admin rank cannot contain emojis.
*/
final class AdminRankEmojiNotAllowedError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ADMIN_RANK_EMOJI_NOT_ALLOWED', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AdminRankInvalidError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AdminRankInvalidError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @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 specified admin rank is invalid.
*/
final class AdminRankInvalidError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ADMIN_RANK_INVALID', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AdminRightsEmptyError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AdminRightsEmptyError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @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 chatAdminRights constructor passed in keyboardButtonRequestPeer.peer_type.user_admin_rights has no rights set (i.e. flags is 0).
*/
final class AdminRightsEmptyError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ADMIN_RIGHTS_EMPTY', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AdminsTooMuchError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AdminsTooMuchError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto\RPCError;

use danog\MadelineProto\RPCErrorException;

/**
* There are too many admins.
*/
final class AdminsTooMuchError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ADMINS_TOO_MUCH', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AlbumPhotosTooManyError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AlbumPhotosTooManyError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto\RPCError;

use danog\MadelineProto\RPCErrorException;

/**
* You have uploaded too many profile photos, delete some before retrying.
*/
final class AlbumPhotosTooManyError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ALBUM_PHOTOS_TOO_MANY', 400, $caller, $previous);
}
}
31 changes: 31 additions & 0 deletions src/RPCError/AnonymousReactionsDisabledError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* AnonymousReactionsDisabledError 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 <[email protected]>
* @copyright 2016-2024 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto\RPCError;

use danog\MadelineProto\RPCErrorException;

/**
* Sorry, anonymous administrators cannot leave reactions or participate in polls.
*/
final class AnonymousReactionsDisabledError extends RPCErrorException
{
public function __construct(string $caller, ?\Exception $previous = null)
{
parent::__construct('ANONYMOUS_REACTIONS_DISABLED', 403, $caller, $previous);
}
}
Loading

0 comments on commit 1a60bfa

Please sign in to comment.