mirror of
https://github.com/weyne85/PentestGPT.git
synced 2025-10-29 16:58:59 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user