Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 1fd6dcf

Browse files
committed
Better messages if settings could not be parsed
SQLTools will display a shorter and more appropriate error message in the status bar and in the console if SQLTools failed to parse Settings and Connections JSON files.
1 parent bb8a39c commit 1fd6dcf

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

SQLTools.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,21 @@ def startPlugin():
5757
QUERIES_FILENAME = os.path.join(USER_FOLDER, SQLTOOLS_QUERIES_FILE)
5858
QUERIES_FILENAME_DEFAULT = os.path.join(DEFAULT_FOLDER, SQLTOOLS_QUERIES_FILE)
5959

60-
settings = Settings(SETTINGS_FILENAME, default=SETTINGS_FILENAME_DEFAULT)
60+
try:
61+
settings = Settings(SETTINGS_FILENAME, default=SETTINGS_FILENAME_DEFAULT)
62+
except Exception as e:
63+
msg = __package__ + ": Failed to parse " + SQLTOOLS_SETTINGS_FILE + " file"
64+
print(msg + "\nError: " + str(e))
65+
Window().status_message(msg)
66+
67+
try:
68+
connections = Settings(CONNECTIONS_FILENAME, default=CONNECTIONS_FILENAME_DEFAULT)
69+
except Exception as e:
70+
msg = __package__ + ": Failed to parse " + SQLTOOLS_CONNECTIONS_FILE + " file"
71+
print(msg + "\nError: " + str(e))
72+
Window().status_message(msg)
73+
6174
queries = Storage(QUERIES_FILENAME, default=QUERIES_FILENAME_DEFAULT)
62-
connections = Settings(CONNECTIONS_FILENAME, default=CONNECTIONS_FILENAME_DEFAULT)
6375
history = History(settings.get('history_size', 100))
6476

6577
Logger.setPackageVersion(__version__)

0 commit comments

Comments
 (0)