mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-10-31 16:07:44 +03:00 
			
		
		
		
	Include full request on the cause of RPC errors
Closes #3110, fixes #3109.
This commit is contained in:
		
							parent
							
								
									2cb6cd5dad
								
							
						
					
					
						commit
						8c56f95252
					
				|  | @ -1,3 +1,15 @@ | |||
| from ..tl import functions | ||||
| 
 | ||||
| _NESTS_QUERY = ( | ||||
|     functions.InvokeAfterMsgRequest, | ||||
|     functions.InvokeAfterMsgsRequest, | ||||
|     functions.InitConnectionRequest, | ||||
|     functions.InvokeWithLayerRequest, | ||||
|     functions.InvokeWithoutUpdatesRequest, | ||||
|     functions.InvokeWithMessagesRangeRequest, | ||||
|     functions.InvokeWithTakeoutRequest, | ||||
| ) | ||||
| 
 | ||||
| class RPCError(Exception): | ||||
|     """Base class for all Remote Procedure Call errors.""" | ||||
|     code = None | ||||
|  | @ -13,7 +25,15 @@ class RPCError(Exception): | |||
| 
 | ||||
|     @staticmethod | ||||
|     def _fmt_request(request): | ||||
|         return ' (caused by {})'.format(request.__class__.__name__) | ||||
|         n = 0 | ||||
|         reason = '' | ||||
|         while isinstance(request, _NESTS_QUERY): | ||||
|             n += 1 | ||||
|             reason += request.__class__.__name__ + '(' | ||||
|             request = request.query | ||||
|         reason += request.__class__.__name__ + ')' * n | ||||
| 
 | ||||
|         return ' (caused by {})'.format(reason) | ||||
| 
 | ||||
|     def __reduce__(self): | ||||
|         return type(self), (self.request, self.message, self.code) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user