Skip to content

Commit 3b338ec

Browse files
committed
enhance error message when sending code
1 parent 4e0633b commit 3b338ec

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

python_files/normalizeSelection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ def traverse_file(whole_file_content, start_line, end_line, was_highlighted): #
162162

163163
try:
164164
parsed_file_content = ast.parse(whole_file_content)
165-
except Exception:
166-
# Handle case where user is attempting to run code where file contains deprecated Python code.
165+
except Exception as e:
166+
# Handle case where user is attempting to run code where file contains invalid Python code.
167167
# Let typescript side know and show warning message.
168168
return {
169-
"normalized_smart_result": "deprecated",
169+
"normalized_smart_result": repr("vscode-python error: " + repr(e)),
170170
"which_line_next": 0,
171171
}
172172

@@ -289,7 +289,7 @@ def get_next_block_lineno(which_line_next):
289289
)
290290
normalized = result["normalized_smart_result"]
291291
which_line_next = result["which_line_next"]
292-
if normalized == "deprecated":
292+
if "vscode-python error: " in normalized:
293293
data = json.dumps(
294294
{"normalized": normalized, "attach_bracket_paste": attach_bracket_paste}
295295
)

src/client/terminals/codeExecution/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
122122
const result = await normalizeOutput.promise;
123123
const object = JSON.parse(result);
124124

125-
if (activeEditor?.selection && smartSendSettingsEnabledVal && object.normalized !== 'deprecated') {
125+
if (activeEditor?.selection && smartSendSettingsEnabledVal && !object.normalized.includes('vscode-python error: ')) {
126126
const lineOffset = object.nextBlockLineno - activeEditor!.selection.start.line - 1;
127127
await this.moveToNextBlock(lineOffset, activeEditor);
128128
}

0 commit comments

Comments
 (0)