Add ErrorInfo

This commit is contained in:
SuperSonic 2019-08-24 11:46:28 +08:00
parent d4cf7eb4f2
commit bd61d2cc41

View file

@ -1,9 +1,11 @@
#!/usr/bin/python3 #!/usr/bin/python3
# coding=UTF-8 # coding=UTF-8
import os, time,\ import os, time, \
requests, \ requests, \
json, ntpath json, ntpath,\
traceback
from libs.core.TalkService import * from libs.core.TalkService import *
from .connection import Yuuki_Connect from .connection import Yuuki_Connect
@ -170,6 +172,10 @@ class Yuuki:
pass pass
except: except:
err1, err2, err3 = sys.exc_info() err1, err2, err3 = sys.exc_info()
traceback.print_tb(err3)
tb_info = traceback.extract_tb(err3)
filename, line, func, text = tb_info[-1]
ErrorInfo = "occurred {} on line {} in statement {}".format(filename, line, text)
try: try:
if catchedNews and ncMessage: if catchedNews and ncMessage:
Finded = False Finded = False
@ -182,8 +188,8 @@ class Yuuki:
if not Finded: if not Finded:
Revision = self.client.getLastOpRevision() Revision = self.client.getLastOpRevision()
for Root in self.Admin: for Root in self.Admin:
self.sendText(Root, "Star Yuuki BOT - Something was wrong...\nError:\n%s\n%s\n%s" % self.sendText(Root, "Star Yuuki BOT - Something was wrong...\nError:\n%s\n%s\n%s\n%s" %
(err1, err2, err3)) (err1, err2, err3, ErrorInfo))
except: except:
print("Star Yuuki BOT - Damage!\nError:\n%s\n%s\n%s" % (err1, err2, err3)) print("Star Yuuki BOT - Damage!\nError:\n%s\n%s\n%s" % (err1, err2, err3))
self.exit() self.exit()
@ -218,4 +224,4 @@ class Yuuki:
Time1 = time.time() Time1 = time.time()
self.sendText(self.sendToWho(ncMessage), _("Testing...")) self.sendText(self.sendToWho(ncMessage), _("Testing..."))
Time2 = time.time() Time2 = time.time()
self.sendText(self.sendToWho(ncMessage), _("Speed:\n%ss") % (Time2 - Time1,)) self.sendText(self.sendToWho(ncMessage), _("Speed:\n{}s").format(Time2 - Time1,))