aboutsummaryrefslogtreecommitdiffstats
path: root/python/vhdl_langserver
diff options
context:
space:
mode:
authorHenning Holm <git@henningholm.de>2020-07-28 11:41:29 +0200
committertgingold <tgingold@users.noreply.github.com>2020-07-30 05:13:09 +0200
commitb65057ed86fbebed802294660c3279a7bd9d9971 (patch)
tree9714c8ffda08acedec79042a9f1c0222fb2ea1ec /python/vhdl_langserver
parent9f60223b124a74d6b6afc857215249714c41207f (diff)
downloadghdl-b65057ed86fbebed802294660c3279a7bd9d9971.tar.gz
ghdl-b65057ed86fbebed802294660c3279a7bd9d9971.tar.bz2
ghdl-b65057ed86fbebed802294660c3279a7bd9d9971.zip
ghdl-ls: Fix exceptions crashing language server
Previously, the language server crashed on any exceptions raised by the handler methods. Catching and logging these exceptions while notify the user about the error results in a much better user experience. This fixes #1410
Diffstat (limited to 'python/vhdl_langserver')
-rw-r--r--python/vhdl_langserver/lsp.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/python/vhdl_langserver/lsp.py b/python/vhdl_langserver/lsp.py
index 983b3005e..8f5a98e5e 100644
--- a/python/vhdl_langserver/lsp.py
+++ b/python/vhdl_langserver/lsp.py
@@ -113,7 +113,20 @@ class LanguageProtocolServer(object):
if fmethod:
if params is None:
params = {}
- response = fmethod(**params)
+ try:
+ response = fmethod(**params)
+ except Exception as e:
+ log.exception(
+ "Caught exception while handling %s with params %s:",
+ method, params
+ )
+ self.show_message(
+ MessageType.Error,
+ ("Caught exception while handling {}, " +
+ "see VHDL language server output for details.").format(
+ method)
+ )
+ response = None
if tid is None:
# If this was just a notification, discard it
return None