#Custom error handling question

1 messages · Page 1 of 1 (latest)

kind lava
#

how would i add an is instance to the on slash command error event for this kind of error?

errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.dev' raised an error: ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection

i am trying to find the equivalent of if isinstance(error, commands.errors.CheckFailure): for the above error

smoky escarpBOT
#
Too Many Tags

Please use either the disnake or python tag, but not both. If your question pertains to disnake, please use the disnake tag. If your question is a general python question that does not depend on disnake, please use the python tag.
I've taken a guess based on the contents of your message which your question is actually about.

If you believe this to be in error, please let us know.

glass bone
#

ConnectionRefusedError is the exception

young urchin
#

so that will come in this i believe

stoic tendonBOT
#

exception disnake.ext.commands.CommandInvokeError(e)```
Exception raised when the command being invoked raised an exception.

This inherits from [`CommandError`](https://docs.disnake.dev/page/ext/commands/api.html#disnake.ext.commands.CommandError "disnake.ext.commands.CommandError")
young urchin
#

it will come under that

kind lava
#

Ah thank you

#

so i got this:
if isinstance(error, commands.errors.CommandInvokeError):

#

which should trigger on the connection refused part

#

but then how do i make it go one step further and if it is the connection refused, send a separate message?

#

would it be like this?

   if error == ConnectionRefusedError:```
glass bone
kind lava
#

ah ok thank ua

#

ya*

wild saddle
#

CommandInvokeError is raised when another error occurs and it holds a reference to it
So to check for both you'd do

if isinstance(error, CommandInvokeError):
    if isinstance(error.original, ConnectionRefusedError):
        # do stuff
    else:
        # not connection error, do other stuff
glass bone
#

aha. error.original Didn't even realize that was a thing