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

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

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

Youll need to code for every exception in here

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

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *