Skip to content

Commit a96d206

Browse files
authored
Error handling when invoke fails (#13)
* Error when invocation fails * More error handling on funcs
1 parent b434d95 commit a96d206

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tasks/func.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def upload(ctx, host="upload", port=8002):
4646
print("Uploading {}/{} to {}".format(USER, FUNC, url))
4747
response = requests.put(url, data=open(WASM_FILE, "rb"))
4848

49-
print("Response {}: {}".format(response.status_code, response.text))
49+
print("Response ({}): {}".format(response.status_code, response.text))
5050

5151

5252
@task
@@ -65,11 +65,7 @@ def uploadpy(ctx, func, local=False, host="upload", port=8002):
6565
url = "http://{}:{}/p/{}/{}".format(host, port, "python", func)
6666
response = requests.put(url, data=open(src_file, "rb"))
6767

68-
print(
69-
"{} response {}: {}".format(
70-
func, response.status_code, response.text
71-
)
72-
)
68+
print("Response ({}): {}".format(response.status_code, response.text))
7369

7470

7571
@task
@@ -104,5 +100,8 @@ def invoke(ctx, user, func, input_data=None, host="worker", port=8080):
104100
data["input_data"] = input_data
105101

106102
response = requests.post(url, json=data)
103+
if response.status_code != 200:
104+
print("Error ({}):\n{}".format(response.status_code, response.text))
105+
exit(1)
107106

108-
print("Response {}:\n{}".format(response.status_code, response.text))
107+
print("Success:\n{}".format(response.text))

0 commit comments

Comments
 (0)