Skip to content

Commit

Permalink
[ABILITY-CALL]: Let ability call raise and show all types of error
Browse files Browse the repository at this point in the history
  • Loading branch information
amadolid committed Aug 14, 2023
1 parent e6d93ce commit 10dbd9c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 6 additions & 6 deletions jaseci_core/jaseci/extens/act_lib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@jaseci_action()
def get(url: str, data: dict, header: dict):
def get(url: str, data: dict = {}, header: dict = {}):
"""
Issue request
Param 1 - url
Expand All @@ -23,7 +23,7 @@ def get(url: str, data: dict, header: dict):


@jaseci_action()
def post(url: str, data: dict, header: dict):
def post(url: str, data: dict = {}, header: dict = {}):
"""
Issue request
Param 1 - url
Expand All @@ -42,7 +42,7 @@ def post(url: str, data: dict, header: dict):


@jaseci_action()
def put(url: str, data: dict, header: dict):
def put(url: str, data: dict = {}, header: dict = {}):
"""
Issue request
Param 1 - url
Expand All @@ -61,7 +61,7 @@ def put(url: str, data: dict, header: dict):


@jaseci_action()
def delete(url: str, data: dict, header: dict):
def delete(url: str, data: dict = {}, header: dict = {}):
"""
Issue request
Param 1 - url
Expand All @@ -80,7 +80,7 @@ def delete(url: str, data: dict, header: dict):


@jaseci_action()
def head(url: str, data: dict, header: dict):
def head(url: str, data: dict = {}, header: dict = {}):
"""
Issue request
Param 1 - url
Expand All @@ -99,7 +99,7 @@ def head(url: str, data: dict, header: dict):


@jaseci_action()
def options(url: str, data: dict, header: dict):
def options(url: str, data: dict = {}, header: dict = {}):
"""
Issue request
Param 1 - url
Expand Down
6 changes: 0 additions & 6 deletions jaseci_core/jaseci/prim/ability.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ def run_action(self, param_list, scope, interp, jac_ast):
else:
try:
result = func(*param_list["args"], **param_list["kwargs"])
except TypeError as e:
params = str(inspect.signature(func))
interp.rt_error(
f"Invalid arguments {param_list} to action call {self.name}! Valid paramters are {params}.",
jac_ast,
)
except Exception as e:
interp.rt_error(e, jac_ast, True)
t = time.time() - ts
Expand Down
2 changes: 1 addition & 1 deletion jaseci_serv/jaseci_serv/jac_api/tests/test_jac_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ def test_try_catch(self):
self.assertEqual(14, res["report"][0]["line"])
self.assertEqual(23, res["report"][0]["col"])
self.assertIn(
"zsb:walker_exception_with_try_else - line 14, col 23 - rule ability_call - Invalid arguments {'args': ['invalidUrl'], 'kwargs': {}} to action call request.get! Valid paramters are (url: str, data: dict, header: dict).",
"zsb:walker_exception_with_try_else - line 14, col 23 - rule ability_call - Invalid URL 'invalidUrl': No scheme supplied. Perhaps you meant https://invalidUrl?",
res["errors"][0],
)

Expand Down

0 comments on commit 10dbd9c

Please sign in to comment.