Skip to content

Commit

Permalink
docs: extend example with new error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
ilfa committed Jan 30, 2023
1 parent f60625a commit d78d12b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ Please follow the [installation procedure](#installation--usage) and then run th

```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import Response
from fingerprint_pro_server_api_sdk.rest import ApiException

# Configure API key authorization and region
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
Expand All @@ -101,7 +99,7 @@ Fetching visits using visitorId:
```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import Response
from fingerprint_pro_server_api_sdk.rest import ApiException
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException

configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
Expand All @@ -115,6 +113,9 @@ limit = 10 # int | Limit scanned results (optional)
try:
api_response: Response = api_instance.get_visits(visitor_id, limit=2)
print(api_response)
except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling DefaultApi->visitors_visitor_id_get: %s\n" % e)
```
Expand All @@ -123,7 +124,7 @@ Fetching events for requestId:
```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import EventResponse
from fingerprint_pro_server_api_sdk.rest import ApiException
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException

configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
Expand All @@ -133,6 +134,9 @@ request_id = 'request_id_example' # str
try:
events_response: EventResponse = api_instance.get_event(request_id)

except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling DefaultApi->get_event: %s\n" % e)
```
Expand Down
12 changes: 8 additions & 4 deletions template/README.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ Please follow the [installation procedure](#installation--usage) and then run th

```python
import {{packageName}}
from {{packageName}} import Response
from {{packageName}}.rest import ApiException

# Configure API key authorization and region
configuration = {{packageName}}.Configuration(api_key="SECRET_API_KEY")
Expand All @@ -109,7 +107,7 @@ Fetching visits using visitorId:
```python
import {{packageName}}
from {{packageName}} import Response
from {{packageName}}.rest import ApiException
from {{packageName}}.rest import ApiException, KnownApiException

configuration = {{packageName}}.Configuration(api_key="SECRET_API_KEY")
api_instance = {{packageName}}.FingerprintApi(configuration)
Expand All @@ -123,6 +121,9 @@ limit = 10 # int | Limit scanned results (optional)
try:
api_response: Response = api_instance.get_visits(visitor_id, limit=2)
print(api_response)
except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling DefaultApi->visitors_visitor_id_get: %s\n" % e)
```
Expand All @@ -131,7 +132,7 @@ Fetching events for requestId:
```python
import {{packageName}}
from {{packageName}} import EventResponse
from {{packageName}}.rest import ApiException
from {{packageName}}.rest import ApiException, KnownApiException

configuration = {{packageName}}.Configuration(api_key="SECRET_API_KEY")
api_instance = {{packageName}}.FingerprintApi(configuration)
Expand All @@ -141,6 +142,9 @@ request_id = 'request_id_example' # str
try:
events_response: EventResponse = api_instance.get_event(request_id)

except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling DefaultApi->get_event: %s\n" % e)
```
Expand Down

0 comments on commit d78d12b

Please sign in to comment.