Exception Hierarchy
MadelineProto uses several exception types to indicate different error conditions:Basic Exception Types
Exception (Base)
The base exception class for general MadelineProto errors:- Includes TL (Type Language) trace for debugging
- Logs fatal errors automatically
- Provides context about where the error occurred
/home/daytona/workspace/source/src/Exception.php:32-56
SecurityException
Indicates a security-related error:/home/daytona/workspace/source/src/SecurityException.php:28
PeerNotInDbException
Thrown when a peer is not found in the local database:RPC Error Exceptions
RPCErrorException
Represents errors returned by Telegram’s API:getMessage()- Raw error string (e.g.,FLOOD_WAIT_42)getCode()- Error codegetDescription()- Human-readable descriptiongetLocalization()- Localized error message
/home/daytona/workspace/source/src/RPCErrorException.php:35-224
Common RPC Errors
Channel/Chat Errors
User Errors
File Errors
Rate Limiting Errors
See the dedicated Flood Wait guide for detailed information on handling rate limits.Quick Example
TL Exceptions
TL (Type Language) exceptions occur during serialization/deserialization:/home/daytona/workspace/source/src/TL/Exception.php:31-47
Best Practices
Catch Specific Exceptions
Use Try-Catch-Finally
Logging Exceptions
Error Reporting
MadelineProto automatically reports unknown RPC errors to help improve error descriptions:/home/daytona/workspace/source/src/RPCErrorException.php:170-212
Exception Helper Methods
getTLTrace()
Get the TL (Type Language) trace for debugging:PrettyException Trait
MadelineProto exceptions include enhanced stack traces showing TL serialization paths:/home/daytona/workspace/source/src/TL/PrettyException.php:29-100
See Also
- Flood Wait Handling - Dealing with rate limits
- Logging - Configuring MadelineProto logging
- API Methods - Complete API documentation