Answer the question
In order to leave comments, you need to log in
How to catch a program crash error?
Hello!
I am writing a program in PyQt. The program is big enough (For me).
When testing, I constantly catch and correct errors through the debugger! (But I can't check everything)
But when I give the program to the workers they will debug. And if an error occurs, the program simply closes!
Question: How to show or record where the error occurred and why?
P.S. My program starts like this:
app = QApplication(sys.argv)
main = form.main_window.MainWindow()
sys.exit(app.exec_())
import sys, traceback
from datetime import datetime
def my_excepthook(t, v, tb):
with open('1.txt', 'a') as f:
f.write("\n---===Error===---\n")
f.write("Time = %s\n" % datetime.now().strftime("%d.%m.%Y"))
traceback.print_exception(t, v, tb, file=f)
sys.excepthook = my_excepthook
app = QApplication(sys.argv)
main = form.main_window.MainWindow()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question