@@ -40,15 +40,18 @@ async def log_error_in_discord(ctx: GitBotContext, error: Exception, _actual=Non
4040 color = 0xda4353 ,
4141 title = f'Error in `{ ctx .command } ` command'
4242 )
43- embed .add_field (name = 'Message' , value = f'```{ error } ```' )
44- embed .add_field (name = 'Traceback' , value = f'```{ format_tb (error .__traceback__ )} ```' )
43+ message : str = ctx .bot .mgr .sanitize_codeblock_content (str (error ))
44+ tb : str = ctx .bot .mgr .sanitize_codeblock_content (format_tb (error .__traceback__ ))
45+ embed .add_field (name = 'Message' , value = f'```{ message } ```' )
46+ embed .add_field (name = 'Traceback' , value = f'```{ tb } ```' )
4547 embed .add_field (name = 'Arguments' ,
46- value = f'```properties\n args={ format_args (ctx .args )} \n kwargs={ format_kwargs (ctx .kwargs )} ```' )
48+ value = f'```properties\n args={ ctx . bot . mgr . sanitize_codeblock_content ( format_args (ctx .args )) } \n kwargs={ ctx . bot . mgr . sanitize_codeblock_content ( format_kwargs (ctx .kwargs ) )} ```' )
4749 elif isinstance (error , commands .CommandNotFound ):
50+ error_text : str = ctx .bot .mgr .sanitize_codeblock_content (str (error ))
4851 embed : GitBotEmbed = GitBotEmbed (
4952 color = 0x0384fc ,
5053 title = 'Nonexistent command!' ,
51- description = f'```{ ( error := str ( error )) } ```' ,
54+ description = f'```{ error_text } ```' ,
5255 footer = 'Closest existing command: ' + closest_existing_command_from_error (ctx .bot , error )
5356 )
5457 elif isinstance (error , (BadRequest , QueryError )):
@@ -57,10 +60,13 @@ async def log_error_in_discord(ctx: GitBotContext, error: Exception, _actual=Non
5760 title = 'GitHub API Error!' ,
5861 footer = 'The logs may contain more information.'
5962 )
60- embed .add_field (name = 'API Response' , value = f'```diff\n - { error } ```' )
61- embed .add_field (name = 'Code Location' , value = f'```{ ctx .gh_query_debug .code_location } ```' )
63+ api_response : str = ctx .bot .mgr .sanitize_codeblock_content (str (error ))
64+ code_location : str = ctx .bot .mgr .sanitize_codeblock_content (ctx .gh_query_debug .code_location )
65+ embed .add_field (name = 'API Response' , value = f'```diff\n - { api_response } ```' )
66+ embed .add_field (name = 'Code Location' , value = f'```{ code_location } ```' )
6267 if ctx .gh_query_debug .additional_info :
63- embed .add_field (name = 'Additional Info' , value = f'```{ ctx .gh_query_debug .additional_info } ```' )
68+ additional_info : str = ctx .bot .mgr .sanitize_codeblock_content (ctx .gh_query_debug .additional_info )
69+ embed .add_field (name = 'Additional Info' , value = f'```{ additional_info } ```' )
6470 if ctx .gh_query_debug .status_code is not None :
6571 embed .add_field (name = 'Status Code' , value = f'```c\n { error .status_code } ```' )
6672 ping_owner : bool = True
0 commit comments