I have a python script and I am using a function from a library where an error is generated for some of the inputs to the function: (Error 200, reqID #####: ....). If an error is generated, then I would like the I would like the script to omit the entry and continue.
I am wondering how to use try - except to catch the error. My script looks as follows:
try:
contracts = ib.qualifyContracts(*contracts)
except ???:
pass
Error 200, reqId 18929: ...
Error 200, reqId 18928: ...
I've tried inserting Error 200 (both with and without quotation) after the except phrase but the errors are not being caught. Any suggestions are appreciated.
Thanks.
EDIT:
I believe the library is library is just printing error messages. Errors look as follows below.
Error 200, reqId 8: No security definition has been found for the request, contract: Option(symbol='SPY', lastTradeDateOrContractMonth='20220921', strike=85.0, right='P', exchange='SMART', tradingClass='SPY')
Error 200, reqId 9: No security definition has been found for the request, contract: Option(symbol='SPY', lastTradeDateOrContractMonth='20220921', strike=90.0, right='P', exchange='SMART', tradingClass='SPY')