Skip to content

Commit 40e9e6a

Browse files
committed
feat: add better error reporting in case of wrong data shape
1 parent 901f2f3 commit 40e9e6a

File tree

4 files changed

+355
-13
lines changed

4 files changed

+355
-13
lines changed

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:
Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
{
2+
"products": {
3+
"identification": {
4+
"data": {
5+
"visitorId": "Ibk1527CUFmcnjLwIs4A9",
6+
"requestId": "1708102555327.NLOjmg",
7+
"incognito": "Chrome",
8+
"linkedId": {
9+
"id": 1234567890
10+
},
11+
"tag": {},
12+
"time": "2019-05-21T16:40:13Z",
13+
"timestamp": 1582299576512,
14+
"url": "https://www.example.com/login?hope{this{works[!",
15+
"ip": "61.127.217.15",
16+
"ipLocation": {
17+
"accuracyRadius": 10,
18+
"latitude": 49.982,
19+
"longitude": 36.2566,
20+
"postalCode": "61202",
21+
"timezone": "Europe/Dusseldorf",
22+
"city": {
23+
"name": "Dusseldorf"
24+
},
25+
"country": {
26+
"code": "DE",
27+
"name": "Germany"
28+
},
29+
"continent": {
30+
"code": "EU",
31+
"name": "Europe"
32+
},
33+
"subdivisions": [
34+
{
35+
"isoCode": "63",
36+
"name": "North Rhine-Westphalia"
37+
}
38+
]
39+
},
40+
"browserDetails": {
41+
"browserName": "Chrome",
42+
"browserMajorVersion": "74",
43+
"browserFullVersion": "74.0.3729",
44+
"os": "Windows",
45+
"osVersion": "7",
46+
"device": "Other",
47+
"userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) ...."
48+
},
49+
"confidence": {
50+
"score": 0.97
51+
},
52+
"visitorFound": false,
53+
"firstSeenAt": {
54+
"global": "2022-03-16T11:26:45.362Z",
55+
"subscription": "2022-03-16T11:31:01.101Z"
56+
},
57+
"lastSeenAt": {
58+
"global": null,
59+
"subscription": null
60+
}
61+
}
62+
},
63+
"botd": {
64+
"data": {
65+
"bot": {
66+
"result": "notDetected"
67+
},
68+
"url": "https://www.example.com/login?hope{this{works}[!",
69+
"ip": "61.127.217.15",
70+
"time": "2019-05-21T16:40:13Z",
71+
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 YaBrowser/24.1.0.0 Safari/537.36",
72+
"requestId": "1708102555327.NLOjmg"
73+
}
74+
},
75+
"rootApps": {
76+
"data": {
77+
"result": false
78+
}
79+
},
80+
"emulator": {
81+
"data": {
82+
"result": false
83+
}
84+
},
85+
"ipInfo": {
86+
"data": {
87+
"v4": {
88+
"address": "94.142.239.124",
89+
"geolocation": {
90+
"accuracyRadius": 20,
91+
"latitude": 50.05,
92+
"longitude": 14.4,
93+
"postalCode": "150 00",
94+
"timezone": "Europe/Prague",
95+
"city": {
96+
"name": "Prague"
97+
},
98+
"country": {
99+
"code": "CZ",
100+
"name": "Czechia"
101+
},
102+
"continent": {
103+
"code": "EU",
104+
"name": "Europe"
105+
},
106+
"subdivisions": [
107+
{
108+
"isoCode": "10",
109+
"name": "Hlavni mesto Praha"
110+
}
111+
]
112+
},
113+
"asn": {
114+
"asn": "7922",
115+
"name": "COMCAST-7922",
116+
"network": "73.136.0.0/13"
117+
},
118+
"datacenter": {
119+
"result": true,
120+
"name": "DediPath"
121+
}
122+
},
123+
"v6": {
124+
"address": "2001:db8:3333:4444:5555:6666:7777:8888",
125+
"geolocation": {
126+
"accuracyRadius": 5,
127+
"latitude": 49.982,
128+
"longitude": 36.2566,
129+
"postalCode": "10112",
130+
"timezone": "Europe/Berlin",
131+
"city": {
132+
"name": "Berlin"
133+
},
134+
"country": {
135+
"code": "DE",
136+
"name": "Germany"
137+
},
138+
"continent": {
139+
"code": "EU",
140+
"name": "Europe"
141+
},
142+
"subdivisions": [
143+
{
144+
"isoCode": "BE",
145+
"name": "Land Berlin"
146+
}
147+
]
148+
},
149+
"asn": {
150+
"asn": "6805",
151+
"name": "Telefonica Germany",
152+
"network": "2a02:3100::/24"
153+
},
154+
"datacenter": {
155+
"result": false,
156+
"name": ""
157+
}
158+
}
159+
}
160+
},
161+
"ipBlocklist": {
162+
"data": {
163+
"result": false,
164+
"details": {
165+
"emailSpam": false,
166+
"attackSource": false
167+
}
168+
}
169+
},
170+
"tor": {
171+
"data": {
172+
"result": false
173+
}
174+
},
175+
"vpn": {
176+
"data": {
177+
"result": false,
178+
"originTimezone": "Europe/Berlin",
179+
"originCountry": "unknown",
180+
"methods": {
181+
"timezoneMismatch": false,
182+
"publicVPN": false,
183+
"auxiliaryMobile": false,
184+
"osMismatch": false
185+
}
186+
}
187+
},
188+
"proxy": {
189+
"data": {
190+
"result": false
191+
}
192+
},
193+
"incognito": {
194+
"data": {
195+
"result": false
196+
}
197+
},
198+
"tampering": {
199+
"data": {
200+
"result": false,
201+
"anomalyScore": 0.1955
202+
}
203+
},
204+
"clonedApp": {
205+
"data": {
206+
"result": false
207+
}
208+
},
209+
"factoryReset": {
210+
"data": {
211+
"time": "1970-01-01T00:00:00Z",
212+
"timestamp": 0
213+
}
214+
},
215+
"jailbroken": {
216+
"data": {
217+
"result": false
218+
}
219+
},
220+
"frida": {
221+
"data": {
222+
"result": false
223+
}
224+
},
225+
"privacySettings": {
226+
"data": {
227+
"result": false
228+
}
229+
},
230+
"virtualMachine": {
231+
"data": {
232+
"result": false
233+
}
234+
},
235+
"rawDeviceAttributes": {
236+
"data": {
237+
"architecture": {
238+
"value": 127
239+
},
240+
"audio": {
241+
"value": 35.73832903057337
242+
},
243+
"canvas": {
244+
"value": {
245+
"Winding": true,
246+
"Geometry": "4dce9d6017c3e0c052a77252f29f2b1c",
247+
"Text": "dd2474a56ff78c1de3e7a07070ba3b7d"
248+
}
249+
},
250+
"colorDepth": {
251+
"value": 30
252+
},
253+
"colorGamut": {
254+
"value": "p3"
255+
},
256+
"contrast": {
257+
"value": 0
258+
},
259+
"cookiesEnabled": {
260+
"value": true
261+
},
262+
"cpuClass": {},
263+
"fonts": {
264+
"value": ["Arial Unicode MS", "Gill Sans", "Helvetica Neue", "Menlo"]
265+
}
266+
}
267+
},
268+
"highActivity": {
269+
"data": {
270+
"result": false
271+
}
272+
},
273+
"locationSpoofing": {
274+
"data": {
275+
"result": false
276+
}
277+
},
278+
"remoteControl": {
279+
"data": {
280+
"result": false
281+
}
282+
},
283+
"velocity": {
284+
"data": {
285+
"distinctIp": {
286+
"intervals": {
287+
"5m": 1,
288+
"1h": 1,
289+
"24h": 1
290+
}
291+
},
292+
"distinctLinkedId": {},
293+
"distinctCountry": {
294+
"intervals": {
295+
"5m": 1,
296+
"1h": 2,
297+
"24h": 2
298+
}
299+
},
300+
"events": {
301+
"intervals": {
302+
"5m": 1,
303+
"1h": 5,
304+
"24h": 5
305+
}
306+
}
307+
}
308+
}
309+
}
310+
}}

0 commit comments

Comments
 (0)