Skip to content

Commit adad032

Browse files
committed
Updated example
Signed-off-by: Patrick Assuied <[email protected]>
1 parent 8cbbecc commit adad032

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

examples/invoke-http/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ expected_stdout_lines:
5151
- '== APP == 200'
5252
- '== APP == error occurred'
5353
- '== APP == MY_CODE'
54+
- '== APP == {"message": "error occurred", "errorCode": "MY_CODE"}'
55+
- '== APP == 503'
56+
- '== APP == Internal Server Error'
5457
background: true
5558
sleep: 5
5659
-->

examples/invoke-http/invoke-caller.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33

44
from dapr.clients import DaprClient
5+
from dapr.clients.exceptions import DaprHttpError
56

67
with DaprClient() as d:
78
req_data = {'id': 1, 'message': 'hello world'}
@@ -29,6 +30,9 @@
2930
http_verb='POST',
3031
data=json.dumps(req_data),
3132
)
32-
except Exception as e:
33-
print(e._message, flush=True)
34-
print(e._error_code, flush=True)
33+
except DaprHttpError as e:
34+
print(e.message, flush=True)
35+
print(e.error_code, flush=True)
36+
print(e.raw_response_bytes, flush=True)
37+
print(str(e.status_code), flush=True)
38+
print(e.reason, flush=True)

0 commit comments

Comments
 (0)