# JSON Decode error catch
* adds error catching on wfs parcel resolving
This commit is contained in:
parent
61046a27c5
commit
e542872fef
@ -93,14 +93,23 @@ class ClientProxyParcelWFS(BaseClientProxyView):
|
|||||||
auth = HTTPDigestAuth(CLIENT_PROXY_AUTH_USER, CLIENT_PROXY_AUTH_PASSWORD)
|
auth = HTTPDigestAuth(CLIENT_PROXY_AUTH_USER, CLIENT_PROXY_AUTH_PASSWORD)
|
||||||
|
|
||||||
content, response_code = self.perform_url_call(url, auth=auth)
|
content, response_code = self.perform_url_call(url, auth=auth)
|
||||||
body = json.loads(content)
|
error_detected = response_code != 200
|
||||||
|
error_code = f"response code:{response_code}"
|
||||||
|
try:
|
||||||
|
body = json.loads(content)
|
||||||
|
except JSONDecodeError:
|
||||||
|
body = {}
|
||||||
|
error_code = "json invalid"
|
||||||
|
error_detected = True
|
||||||
|
|
||||||
body["crs"] = {
|
body["crs"] = {
|
||||||
"type": "name",
|
"type": "name",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": "urn:ogc:def:crs:EPSG::25832"
|
"name": "urn:ogc:def:crs:EPSG::25832",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if response_code != 200:
|
if error_detected:
|
||||||
|
body["crs"]["properties"]["msg"] = f"Error detected ({error_code})"
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
"status_code": response_code,
|
"status_code": response_code,
|
||||||
"content": body,
|
"content": body,
|
||||||
|
Loading…
Reference in New Issue
Block a user