Skip to content

Commit 880b083

Browse files
authored
Show error message on evaluate also for hover context (#2006)
If a client sends an evaluate command with context=hover and if the expression fails, the client received an error with the message "Exception occurred during evaluation" This wasn't very helpful. This changes the logic to treat `hover` just like `watch` in the error case to send back `eval_result.result`. That contains the message of the exception which is typically more useful.
1 parent 2801e48 commit 880b083

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,8 @@ def __create_frame():
12141214
eval_result = pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=False)
12151215
is_error = isinstance_checked(eval_result, ExceptionOnEvaluate)
12161216
if is_error:
1217-
if context == "hover": # In a hover it doesn't make sense to do an exec.
1218-
_evaluate_response(py_db, request, result="", error_message="Exception occurred during evaluation.")
1219-
return
1220-
elif context == "watch":
1221-
# If it's a watch, don't show it as an exception object, rather, format
1217+
if context in ["watch", "hover"]:
1218+
# If it's hover or watch, don't show it as an exception object, rather, format
12221219
# it and show it as a string (with success=False).
12231220
msg = "%s: %s" % (
12241221
eval_result.result.__class__.__name__,

0 commit comments

Comments
 (0)