feat: 🎸 minor logic improvement

Add exception handling in main loop so that logs can also be saved even
when error occurs.
This commit is contained in:
Grey_D
2023-04-27 18:06:03 +08:00
parent 351e9ad8ee
commit 27dfd7706d

View File

@@ -481,11 +481,19 @@ class pentestGPT:
# 4. enter the main loop.
while True:
result = self.input_handler()
self.console.print(
"-----------------------------------------", style="bold white"
)
if not result: # end the session
try:
result = self.input_handler()
self.console.print(
"-----------------------------------------", style="bold white"
)
if not result: # end the session
break
except Exception as e: # catch all general exception.
# log the exception
self.log_conversation("exception", "e")
# print the exception
self.console.print("Exception: " + str(e), style="bold red")
# safely quit the session
break
# Summarize the session and end