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

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

lukejriddle
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor 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
@fabioz
Copy link
Owner

fabioz commented Oct 5, 2024

Sorry for the long time to review this. The change seems fine. Do you think you can fix the conflicts and resubmit?

@lukejriddle
Copy link
Contributor Author

Done, thanks.

@fabioz fabioz merged commit 7d6e6e6 into fabioz:main Oct 17, 2024
8 checks passed
@fabioz
Copy link
Owner

fabioz commented Oct 17, 2024

Just merged. Thanks for the PR.

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.

2 participants