MCPcopy Create free account
hub / github.com/RocketGod-git/shodanbot / handle_errors

Function handle_errors

main.py:159–182  ·  view source on GitHub ↗
(interaction, error, error_type="Error")

Source from the content-addressed store, hash-verified

157client = None
158
159async def handle_errors(interaction, error, error_type="Error"):
160 error_message = f"{error_type}: {error}"
161 logger.error(f"Error occurred for user {interaction.user} in {interaction.guild.name if interaction.guild else 'Direct Message'}: {error_message}")
162
163 try:
164 # Check if the interaction has been responded to
165 if interaction.response.is_done():
166 await interaction.followup.send(error_message)
167 else:
168 await interaction.response.send_message(error_message, ephemeral=True)
169 except discord.HTTPException as http_err:
170 logger.warning(f"HTTP error while responding to {interaction.user}: {http_err}")
171 try:
172 await interaction.followup.send(error_message)
173 except discord.HTTPException as followup_http_err:
174 logger.error(f"HTTP error during followup to {interaction.user}: {followup_http_err}")
175 except Exception as unexpected_followup_error:
176 logger.error(f"Unexpected error during followup to {interaction.user}: {unexpected_followup_error}")
177 except Exception as unexpected_err:
178 logger.error(f"Unexpected error while responding to {interaction.user}: {unexpected_err}")
179 try:
180 await interaction.followup.send("An unexpected error occurred. Please try again later.")
181 except Exception as followup_error:
182 logger.error(f"Failed to send followup: {followup_error}")
183
184async def process_shodan_results(interaction: discord.Interaction, result: dict, max_results: int = 10, display_mode: str = "full"):
185 user = interaction.user.name

Callers 14

hostinfoFunction · 0.85
protocolsFunction · 0.85
searchFunction · 0.85
searchcityFunction · 0.85
searchorgFunction · 0.85
searchportFunction · 0.85
searchcountryFunction · 0.85
exploitsearchFunction · 0.85
listtagsFunction · 0.85
searchnetblockFunction · 0.85
searchproductFunction · 0.85
searchsslFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected