mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-11-04 01:47:27 +03:00 
			
		
		
		
	Report errors in the background not to interfer with users (#262)
This commit is contained in:
		
							parent
							
								
									c0ee123156
								
							
						
					
					
						commit
						01c91bb895
					
				| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
import urllib.request
 | 
					import urllib.request
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					from threading import Thread
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .common import (
 | 
					from .common import (
 | 
				
			||||||
    ReadCancelledError, InvalidParameterError, TypeNotFoundError,
 | 
					    ReadCancelledError, InvalidParameterError, TypeNotFoundError,
 | 
				
			||||||
| 
						 | 
					@ -18,8 +19,7 @@ from .rpc_errors_401 import *
 | 
				
			||||||
from .rpc_errors_420 import *
 | 
					from .rpc_errors_420 import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def rpc_message_to_error(code, message, report_method=None):
 | 
					def report_error(code, message, report_method):
 | 
				
			||||||
    if report_method is not None:
 | 
					 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        # Ensure it's signed
 | 
					        # Ensure it's signed
 | 
				
			||||||
        report_method = int.from_bytes(
 | 
					        report_method = int.from_bytes(
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,14 @@ def rpc_message_to_error(code, message, report_method=None):
 | 
				
			||||||
    except:
 | 
					    except:
 | 
				
			||||||
        "We really don't want to crash when just reporting an error"
 | 
					        "We really don't want to crash when just reporting an error"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def rpc_message_to_error(code, message, report_method=None):
 | 
				
			||||||
 | 
					    if report_method is not None:
 | 
				
			||||||
 | 
					        Thread(
 | 
				
			||||||
 | 
					            target=report_method,
 | 
				
			||||||
 | 
					            args=(code, message, report_method)
 | 
				
			||||||
 | 
					        ).start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    errors = {
 | 
					    errors = {
 | 
				
			||||||
        303: rpc_errors_303_all,
 | 
					        303: rpc_errors_303_all,
 | 
				
			||||||
        400: rpc_errors_400_all,
 | 
					        400: rpc_errors_400_all,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user