Skip to content

Commit 84e4409

Browse files
committed
Some corrections to make sure parsing errors are reported to the user
1 parent f33e032 commit 84e4409

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

application/application.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import traceback
12
from copy import deepcopy
23

4+
35
from PythonVoiceCodingPlugin.queries import *
46
from PythonVoiceCodingPlugin.application.build_cache import BuildCache
57
from PythonVoiceCodingPlugin.application.state_update import clear_state,retrieve_state,retrieve_text,get_location_text,update_changes,update_origin,horizontal_to_vertical
@@ -55,16 +57,13 @@ def respond_to_query(self,interface,query_description,secondary=False):
5557
code = view_information["code"]
5658
change_count = view_information["change_count"]
5759
latest_build = Application.build_cache.get_build(self.vid,change_count)
58-
print("state\n\n",self.state,"\n\n")
60+
# print("state\n\n",self.state,"\n\n")
5961
try:
6062
if not secondary:
61-
print("and during inside here ",query_description)
6263
need_update = retrieve_state(self.state,view_information,code)
6364

6465
except:
6566
clear_state(self.state)
66-
if False:
67-
raise
6867

6968
# get the corresponding query and execute it
7069
s = get_query(query_description)(code,latest_build)
@@ -76,17 +75,18 @@ def respond_to_query(self,interface,query_description,secondary=False):
7675
try:
7776
s(view_information,query_description,extra)
7877
except Exception as e:
79-
if not s.exceptions_raised:
80-
print("inside exceptions raised",e)
81-
raise
78+
# check if there are exceptions with parsing
79+
if s.exceptions_raised:
80+
interface.clear_actions()
81+
interface.push_action(PopUpErrorAction(str(s.exceptions_raised)))
8282
return False
83-
8483

85-
# check if there are exceptions
86-
if s.exceptions_raised:
8784
interface.clear_actions()
88-
interface.push_action(PopUpErrorAction(str(s.exceptions_raised)))
85+
traceback.print_exc()
8986
return False
87+
88+
89+
9090

9191

9292
# register build for later use
@@ -171,7 +171,7 @@ def respond_to_query(self,interface,query_description,secondary=False):
171171
for name in ["result","origin", "initial_origin"]:
172172
interface.push_action(HighlightCleverAction(self.state[name],name))
173173

174-
print("\nBefore exiting query:\n",self.state,"\n")
174+
# print("\nBefore exiting query:\n",self.state,"\n")
175175
if secondary_query_description and should_execute_secondary:
176176
interface.push_action(ClearHighlightAction("alternatives"))
177177
secondary_success = self.respond_to_query(interface,secondary_query_description,secondary=True)

0 commit comments

Comments
 (0)