close

[Solved] Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed Error Occurs?

Today I get the following error Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed in python.

How To Solve Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed Error ?

  1. How To Solve Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed Error ?

    To Solve Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed Error The error occurs because in the exception clause you must indicate which exception you capture. An exception is a class that inherits (directly or indirectly) from the base class Exception.

  2. Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed

    To Solve Python 3 handling error TypeError: catching classes that do not inherit from BaseException is not allowed Error The error occurs because in the exception clause you must indicate which exception you capture. An exception is a class that inherits (directly or indirectly) from the base class Exception.

Solution 1

I post the question in Spanish Stack with better results. To translate and sum up: The error occurs because in the exception clause you must indicate which exception you capture. An exception is a class that inherits (directly or indirectly) from the base class Exception.

Instead I have put client.get_order where python expected the name of the exception, and what you have put is a method of an object, and not a class that inherits from Exception.

The solution goes this way

try:
    SellSta=client.get_order(symbol=Symb,orderId=SellOrderNum,recvWindow=Delay)
except Exception as e:
    if e.code==-2013:
        print ("Order does not exist.");
    elif e.code==-2014:
        print ("API-key format invalid.");
    #End If

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read