Skip to content

Commit fb80e9e

Browse files
authored
Merge pull request #57 from fingerprintjs/INTER-795-improve-response-transparency
Add better error reporting in case of wrong data shape
2 parents 901f2f3 + 9dc220a commit fb80e9e

File tree

9 files changed

+400
-84
lines changed

9 files changed

+400
-84
lines changed

.github/workflows/coverage-diff.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-python@v5
1313
with:
14-
python-version: "3.9"
14+
python-version: "3.12"
1515
- name: "Install dependencies"
1616
run: |
1717
python -m pip install --upgrade pip
@@ -22,7 +22,7 @@ jobs:
2222
coverage run --source=fingerprint_pro_server_api_sdk -m pytest
2323
coverage xml
2424
- name: Get Cover
25-
uses: orgoro/coverage@d77626a5fa35d39123e86d6c62907fabe2491496
25+
uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac
2626
with:
2727
coverageFile: ./coverage.xml
28-
token: ${{ secrets.GITHUB_TOKEN }}
28+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/coverage-report.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-python@v5
1616
with:
17-
python-version: "3.9"
17+
python-version: "3.12"
1818
- name: "Install dependencies"
1919
run: |
2020
python -m pip install --upgrade pip
@@ -38,4 +38,4 @@ jobs:
3838
uses: JamesIves/github-pages-deploy-action@8817a56e5bfec6e2b08345c81f4d422db53a2cdc
3939
with:
4040
branch: gh-pages
41-
folder: htmlcov
41+
folder: htmlcov

.github/workflows/functional_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616
- uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.9"
18+
python-version: "3.12"
1919
- name: "Install dependencies"
2020
run: |
2121
python -m pip install --upgrade pip

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
with:
1313
appId: ${{ vars.APP_ID }}
1414
language: python
15-
language-version: '3.9'
15+
language-version: '3.12'
1616
semantic-release-extra-plugins: |
1717
1818
prepare-command: |

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10" ]
1717

1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
2020
- uses: actions/setup-python@v5
2121
with:
2222
python-version: "${{ matrix.python-version }}"

fingerprint_pro_server_api_sdk/api_client.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from fingerprint_pro_server_api_sdk.configuration import Configuration
2525
import fingerprint_pro_server_api_sdk.models
2626
from fingerprint_pro_server_api_sdk import rest
27+
from fingerprint_pro_server_api_sdk.rest import ApiException
2728

2829

2930
class ApiClient(object):
@@ -161,12 +162,17 @@ def __call_api(
161162
self.last_response = response_data
162163

163164
return_data = response_data
164-
if _preload_content:
165-
# deserialize response data
166-
if response_type:
167-
return_data = self.deserialize(response_data, response_type)
168-
else:
169-
return_data = None
165+
try:
166+
if _preload_content:
167+
# deserialize response data
168+
if response_type:
169+
return_data = self.deserialize(response_data, response_type)
170+
else:
171+
return_data = None
172+
except ValueError as e:
173+
error = ApiException(http_resp=response_data)
174+
error.reason = e
175+
raise error
170176

171177
if _return_http_data_only:
172178
return (return_data)

template/api_client.mustache

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import tornado.gen
1919
from {{packageName}}.configuration import Configuration
2020
import {{modelPackage}}
2121
from {{packageName}} import rest
22+
from {{packageName}}.rest import ApiException
2223

2324

2425
class ApiClient(object):
@@ -159,12 +160,17 @@ class ApiClient(object):
159160
self.last_response = response_data
160161

161162
return_data = response_data
162-
if _preload_content:
163-
# deserialize response data
164-
if response_type:
165-
return_data = self.deserialize(response_data, response_type)
166-
else:
167-
return_data = None
163+
try:
164+
if _preload_content:
165+
# deserialize response data
166+
if response_type:
167+
return_data = self.deserialize(response_data, response_type)
168+
else:
169+
return_data = None
170+
except ValueError as e:
171+
error = ApiException(http_resp=response_data)
172+
error.reason = e
173+
raise error
168174

169175
{{^tornado}}
170176
if _return_http_data_only:

0 commit comments

Comments
 (0)