Thank you so much for helping me.
I use try...except to tell me where has error,but it can't tell me where the error occurred, it will report an error in the upper function.
Such as that:
main -> processContent -> processPosition -> setPosition
main:
try:
SpiderProcess.processContent(results,connect)
except Exception as e:
log.write("process error:" + str(e))
continue
processContent:
try:
SpiderProcess.processPosition(result,connect,ID)
except Exception as e:
Log().write("ID:" + ID)
Log().write("processPosition error:" + str(e))
processPosition:
try:
Database.setPosition(connect,ID,district,region,community)
#print("3")
except Exception as e:
Log().write("ID:" + ID)
Log().write("setPosition error:" + str(e))
return
setPosition:
sql9 = "UPDATE Position SET district = '{0}', region = '{1}' , community = '{2}' WHERE ID = {7}".format(district,region,community,ID)
At the end, I knew it was "7" error ,but my log file suggested that the error was:
process error:must be str, not int
main -> processContent -> processPosition -> setPosition
I write try...except anywhere. but at the end i need to use print("") to know where has error.
Thank you so much for helping me
question from:
https://stackoverflow.com/questions/66059347/i-use-try-except-to-tell-me-where-has-error-but-it-cant-tell-me-where-the-err 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…