Skip to content

Commit

Permalink
[TRY-CATCH]: Enhancement on else (catch) block; Fix uncovered run act…
Browse files Browse the repository at this point in the history
…ion on try catch
  • Loading branch information
amadolid committed Aug 29, 2023
1 parent 520e3c6 commit 855a384
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 3 additions & 1 deletion jaseci_core/jaseci/jac/interpreter/interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ def run_try_stmt(self, jac_ast):
self._jac_try_mode += 1
try:
self.run_code_block(kid[1])
self._jac_try_mode -= 1
except TryException as e:
self._jac_try_mode -= 1
if len(kid) > 2:
self.run_else_from_try(kid[2], e.ref)
except Exception as e:
self._jac_try_mode -= 1
if len(kid) > 2:
self.run_else_from_try(kid[2], self.jac_exception(e, kid[2]))
self._jac_try_mode -= 1

def run_else_from_try(self, jac_ast, jac_ex):
"""
Expand Down
19 changes: 7 additions & 12 deletions jaseci_core/jaseci/prim/ability.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,17 @@ def run_action(self, param_list, scope, interp, jac_ast):
action_manager.pre_action_call_hook()

ts = time.time()
if "meta" in args:
result = func(
*param_list["args"],
**param_list["kwargs"],
meta={
try:
if "meta" in args:
param_list["kwargs"]["meta"] = {
"m_id": scope.parent._m_id,
"h": scope.parent._h,
"scope": scope,
"interp": interp,
},
)
else:
try:
result = func(*param_list["args"], **param_list["kwargs"])
except Exception as e:
interp.rt_error(e, jac_ast, True)
}
result = func(*param_list["args"], **param_list["kwargs"])
except Exception as e:
interp.rt_error(e, jac_ast, True)
t = time.time() - ts
action_manager.post_action_call_hook(action_name, t)
return result
Expand Down

0 comments on commit 855a384

Please sign in to comment.