Skip to content

Commit b345370

Browse files
Added error message for sqlalchemy (RhinoSecurityLabs#189)
* Added error message for sqlalchemy * Fix indentation and writing style consistency Co-authored-by: BFriedland <[email protected]>
1 parent 1dd2053 commit b345370

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pacu.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from core.models import AWSKey, PacuSession
2626
from setup_database import setup_database_if_not_present
27+
from sqlalchemy import exc
2728
from utils import get_database_connection, set_sigint_handler
2829
except ModuleNotFoundError as error:
2930
exception_type, exception_value, tb = sys.exc_info()
@@ -813,7 +814,6 @@ def export_keys(self, command):
813814
else:
814815
return
815816

816-
817817
###### Some module notes
818818
# For any argument that needs a value and a region for that value, use the form
819819
# value@region
@@ -1577,6 +1577,19 @@ def run_gui(self):
15771577
local_data=local_data,
15781578
global_data=global_data
15791579
)
1580+
1581+
# Catch sqlalchemy error
1582+
elif exception_type == exc.OperationalError:
1583+
traceback_text = '\nTraceback (most recent call last):\n{}{}: {}\n\n'.format(''.join(traceback.format_tb(tb)), str(exception_type), str(exception_value))
1584+
session, global_data, local_data = self.get_data_from_traceback(tb)
1585+
self.log_error(
1586+
traceback_text,
1587+
exception_info='{}: {}\n\nPacu database error. This could be caused by a recent update in Pacu\'s database\'s structure. If your Pacu has been updated recently, try removing your old db.sqlite3 database file.'.format(exception_type, exception_value),
1588+
session=session,
1589+
local_data=local_data,
1590+
global_data=global_data
1591+
)
1592+
15801593
else:
15811594
traceback_text = '\nTraceback (most recent call last):\n{}{}: {}\n\n'.format(''.join(traceback.format_tb(tb)), str(exception_type), str(exception_value))
15821595
session, global_data, local_data = self.get_data_from_traceback(tb)

0 commit comments

Comments
 (0)