@@ -130,24 +130,40 @@ def _handleError(self, e: Exception, repoName: str, *args, **kwargs) -> None:
130130 if self .extraInfo :
131131 description += f"\n Extra Info: { self .kwargs } "
132132
133+ # shortened description for discord if too long (shortens the error text)
134+ start = f"# { title } \n \n Type: { excType } \n Error text: "
135+ compress = f"{ e } \n Traceback: { traceback .format_exc ()} "
136+ end = f"\n \n Function Name: { functionName } \n Arguments: { args } \n Keyword Arguments: { kwargs } "
137+ if self .extraInfo :
138+ end += f"\n Extra Info: { self .kwargs } "
139+
140+ staticLength = len (start ) + len (end )
141+ if staticLength > 2000 :
142+ shortDescription = f"# { title } \n \n " + description [:2000 - len (f"# { title } \n \n " ) - 3 ] + "..."
143+ else :
144+ shortDescription = f"{ start } { compress [:2000 - staticLength ]} { end } "
145+
146+ print (f"SHORT DESCRIPTION with length { len (shortDescription )} :\n { shortDescription } " )
147+
148+
133149 # Check if we need to send a bug report
134150 if not self .handlers [repoName ].test :
135- self ._sendBugReport (repoName , title , description )
151+ self ._sendBugReport (repoName , title , description , shortDescription )
136152
137153 print (title )
138154 print (description )
139155 raise e
140156
141- def _sendBugReport (self , repoName : str , errorTitle : str , errorMessage : str ) -> None :
157+ def _sendBugReport (self , repoName : str , errorTitle : str , errorMessage : str , shortErrorMessage : str ) -> None :
142158 """Sends a bug report to the Github repository.
143159
144160 Args:
145161 errorTitle (str): the title of the error
146162 errorMessage (str): the error message
147163 """
148- asyncio .run (self ._sendBugReport_async (repoName , errorTitle , errorMessage ))
164+ asyncio .run (self ._sendBugReport_async (repoName , errorTitle , errorMessage , shortErrorMessage ))
149165
150- async def _sendBugReport_async (self , repoName : str , errorTitle : str , errorMessage : str ) -> None :
166+ async def _sendBugReport_async (self , repoName : str , errorTitle : str , errorMessage : str , shortErrorMessage : str ) -> None :
151167 """Sends a bug report to the Github repository asynchronously.
152168
153169 Args:
@@ -197,7 +213,7 @@ async def _sendBugReport_async(self, repoName: str, errorTitle: str, errorMessag
197213 # Send to Discord if applicable
198214 if self .handlers [repoName ].useDiscord :
199215 discordBot = DiscordBot (self .handlers [repoName ].botToken , self .handlers [repoName ].channelId )
200- await discordBot .send_message (f"## { repoName } : { errorTitle } \n { errorMessage } " , issueExists )
216+ await discordBot .send_message (shortErrorMessage , issueExists )
201217
202218 if (not issueExists ):
203219 result = await client .execute_async (query = createIssue , variables = variables , headers = headers )
0 commit comments