Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exception thrown when executing invalid expression #276

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lukejriddle
Copy link

@lukejriddle lukejriddle commented Mar 27, 2024

If an invalid expression is evaluated, the attempt to exec said expression results in an exception. Since the code omits an except clause and only does try finally, the exception is not properly discarded without a return, break, or continue statement: reference.

This resulted in the debugger hanging indefinitely when an invalid expression was evaluated. The exception would show in the console, but the stepping/continuing would stop working.

This PR fixes this issue by adding the except clause and logging the exception. This allows the debugger to continue executing.

This PR fixes this issue by properly handling the exception in the calling method (see comments below)

@lukejriddle
Copy link
Author

I should note that this only happens when internal_set_expression_json is called -- as part of a setExpression DAP call -- and that this issue doesn't occur when internal_evaluate_expression_json is called -- from the repl.

This is because the former expects a return value from evaluate_expression, but that function will never return anything since is_exec=True. This results in the error check always failing. The latter properly wraps it in a try except.

@lukejriddle
Copy link
Author

lukejriddle commented Mar 27, 2024

It also appears that if is_error were ever actually true, which it never will be since the function doesn't return anything, there'd be a runtime exception. Creating a SetExpressionResponseBody is done improperly; it expects value in the constructor.

Same for these lines. I'm guessing this condition is never true, which makes sense from the comment.

@lukejriddle
Copy link
Author

Added a new commit to address the above ^

@lukejriddle lukejriddle changed the title Handle exception thrown when evaluating invalid expression Handle exception thrown when executing invalid expression Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant