Skip to content

Commit

Permalink
[TRY-CATCH]: Clean up unreachable codes
Browse files Browse the repository at this point in the history
  • Loading branch information
amadolid committed Jul 25, 2023
1 parent c96eb75 commit 78a327a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion jaseci_core/jaseci/extens/api/webhook_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ def webhook(self, provider: str, _req_ctx: dict = {}):
)
else:
raise HTTPException(
status_code=400, detail=str(type + " webhook is not yet supported")
status_code=400, detail=str(provider + " webhook is not yet supported")
)
1 change: 0 additions & 1 deletion jaseci_core/jaseci/jac/interpreter/architype_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def run_graph_block(self, jac_ast):
return obj
else:
self.rt_error("Graph didn't produce root node!", kid[3])
return None

def run_has_root(self, jac_ast):
"""
Expand Down
27 changes: 5 additions & 22 deletions jaseci_core/jaseci/jac/interpreter/interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ def run_for_stmt(self, jac_ast):
self._loop_ctrl = None
break
if loops > self._loop_limit:
self.rt_error("Hit loop limit, breaking...", kid[0])
self._loop_ctrl = "break"
self.rt_error(f"Hit loop limit [{self._loop_limit}]!", kid[0])
self.run_expression(kid[3])
elif kid[3].name == "expression":
var = self._jac_scope.get_live_var(kid[1].token_text(), create_mode=True)
Expand All @@ -240,8 +239,7 @@ def run_for_stmt(self, jac_ast):
self._loop_ctrl = None
break
if loops > self._loop_limit:
self.rt_error("Hit loop limit, breaking...", kid[0])
self._loop_ctrl = "break"
self.rt_error(f"Hit loop limit [{self._loop_limit}]!", kid[0])
else:
self.rt_error("Not a list/dict for iteration!", kid[3])
else:
Expand Down Expand Up @@ -269,8 +267,7 @@ def run_for_stmt(self, jac_ast):
self._loop_ctrl = None
break
if loops > self._loop_limit:
self.rt_error("Hit loop limit, breaking...", kid[0])
self._loop_ctrl = "break"
self.rt_error(f"Hit loop limit [{self._loop_limit}]!", kid[0])
else:
self.rt_error("Not a list/dict for iteration!", kid[5])
if self._loop_ctrl and self._loop_ctrl == "continue":
Expand All @@ -291,8 +288,7 @@ def run_while_stmt(self, jac_ast):
self._loop_ctrl = None
break
if loops > self._loop_limit:
self.rt_error("Hit loop limit, breaking...", kid[0])
self._loop_ctrl = "break"
self.rt_error(f"Hit loop limit [{self._loop_limit}]!", kid[0])
self.run_expression(kid[1])
if self._loop_ctrl and self._loop_ctrl == "continue":
self._loop_ctrl = None
Expand Down Expand Up @@ -625,17 +621,11 @@ def run_global_ref(self, jac_ast):
# Add additional accessible fields
return JacValue(self, value=self.get_info())
else:
self.rt_error(f"Global {kid[0].name} not yet", jac_ast)
return JacValue(
self,
)
self.rt_error(f"Global {kid[0].name} is not supported!", jac_ast)
else:
token = kid[2].token_text()
if token not in self.parent().global_vars:
self.rt_error(f"Global not defined - {token}", kid[2])
return JacValue(
self,
)

return JacValue(self, ctx=self.parent().global_vars, name=token)

Expand Down Expand Up @@ -803,7 +793,6 @@ def run_ability_op(self, jac_ast, atom_res):
return self.parent().arch_ids.get_obj_by_name(name=name, kind=kind)
else:
self.rt_error(f"{name} is not a super arch of {base_arch.name}", kid[1])
return None
else:
return base_arch

Expand Down Expand Up @@ -838,7 +827,6 @@ def run_deref(self, jac_ast):
return JacValue(self, value=nd)

self.rt_error(f"{result.value} not valid reference", kid[1])
return result

def run_built_in(self, jac_ast, atom_res):
"""
Expand Down Expand Up @@ -960,7 +948,6 @@ def run_dict_built_in(self, jac_ast, atom_res):
self.rt_error(
f"Cannot get keys of {atom_res}. " f"Not Dictionary!", kid[0]
)
return JacValue(self, value=[])
elif len(kid) > 1 and kid[1].name == "name_list":
filter_on = self.run_name_list(kid[1])
d = atom_res.value
Expand Down Expand Up @@ -1032,7 +1019,6 @@ def run_list_built_in(self, jac_ast, atom_res):
self.rt_error(
f"Cannot get length of {atom_res.value}. Not List!", kid[0]
)
return JacValue(self, value=0)
else:
if not self.rt_check_type(atom_res.value, [list], kid[0]):
return atom_res
Expand Down Expand Up @@ -1408,7 +1394,6 @@ def run_index_slice(self, jac_ast, atom_res):
f"Indicies must be an integer or string!",
kid[1],
)
return atom_res
try:
return JacValue(self, ctx=atom_res.value, name=idx)
except Exception as e:
Expand All @@ -1423,7 +1408,6 @@ def run_index_slice(self, jac_ast, atom_res):
"List slice range not valid. Indicies must be an integers!",
kid[1],
)
return atom_res
try:
return JacValue(self, ctx=atom_res.value, name=idx, end=end)
except Exception as e:
Expand Down Expand Up @@ -1663,7 +1647,6 @@ def run_filter_compare(self, jac_ast, obj):
return self.pop().value
else:
self.rt_error(f"{name} not present in object", kid[0])
return False

def run_any_type(self, jac_ast):
"""
Expand Down
5 changes: 4 additions & 1 deletion jaseci_core/jaseci/prim/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ def get_arch_for(self, obj):
"""Returns the architype that matches object"""
ret = self.arch_ids.get_obj_by_name(name=obj.name, kind=obj.kind)
if ret is None:
self.rt_error(f"Unable to find architype for {obj.name}, {obj.kind}")
self.rt_error(
f"Unable to find architype for {obj.name}, {obj.kind}",
self._cur_jac_ast,
)
return ret

def run_tests(self, specific=None, profiling=False, detailed=False, silent=False):
Expand Down

0 comments on commit 78a327a

Please sign in to comment.