improved the traceback messages

This commit is contained in:
b3yond 2018-01-04 12:20:59 +01:00
parent aa45a8e814
commit 98dd5e4212
3 changed files with 29 additions and 13 deletions

View file

@ -130,9 +130,14 @@ if __name__ == '__main__':
bot.retoot()
time.sleep(1)
except KeyboardInterrupt:
print("Good bye! Remember to restart the bot.")
print("Good bye. Remember to restart the bot!")
except:
tb = traceback.extract_tb(sys.exc_info()[2])
bot.logger.log(tb)
print()
bot.shutdown(tb)
exc = sys.exc_info() # returns tuple [Exception type, Exception object, Traceback object]
tb = traceback.extract_tb(exc[2]) # returns StackSummary object
tb = "\n".join(tb.format()) # string of the actual traceback
message = ("Traceback (most recent call last):\n",
tb,
exc[0].__name__) # the type of the Exception
message = "".join(message) # concatenate to full traceback message
bot.logger.log(message)
bot.shutdown(message)

View file

@ -251,9 +251,14 @@ if __name__ == "__main__":
bot.flow()
sleep(60)
except KeyboardInterrupt:
print("Good bye! Remember to restart the bot.")
print("Good bye. Remember to restart the bot!")
except:
tb = traceback.extract_tb(sys.exc_info()[2])
bot.logger.log(tb)
print()
bot.shutdown(tb)
exc = sys.exc_info() # returns tuple [Exception type, Exception object, Traceback object]
tb = traceback.extract_tb(exc[2]) # returns StackSummary object
tb = "\n".join(tb.format()) # string of the actual traceback
message = ("Traceback (most recent call last):\n",
tb,
exc[0].__name__) # the type of the Exception
message = "".join(message) # concatenate to full traceback message
bot.logger.log(message)
bot.shutdown(message)

View file

@ -35,6 +35,12 @@ if __name__ == '__main__':
except KeyboardInterrupt:
print("Good bye. Remember to restart the bot!")
except:
tb = traceback.extract_tb(sys.exc_info()[2])
tbot.logger.log(tb)
tbot.shutdown(tb)
exc = sys.exc_info() # returns tuple [Exception type, Exception object, Traceback object]
tb = traceback.extract_tb(exc[2]) # returns StackSummary object
tb = "\n".join(tb.format()) # string of the actual traceback
message = ("Traceback (most recent call last):\n",
tb,
exc[0].__name__) # the type of the Exception
message = "".join(message) # concatenate to full traceback message
tbot.logger.log(message)
tbot.shutdown(message)