Server: Better error handling and provide error details

This commit is contained in:
Raúl Marín
2020-11-17 17:41:54 +01:00
parent 151d8f01e4
commit 314e709f3b
5 changed files with 7 additions and 6 deletions

View File

@@ -66,11 +66,12 @@ RETURNS cdb_dataservices_server.simple_route AS $$
import sys
service_manager.quota_service.increment_failed_service_use()
service_manager.logger.error('Error trying to calculate Mapbox routing', sys.exc_info(), data={"username": username, "orgname": orgname})
raise Exception('Error trying to calculate Mapbox routing')
raise Exception('Error trying to calculate Mapbox routing: ' + str(e))
finally:
service_manager.quota_service.increment_total_service_use()
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
CREATE OR REPLACE FUNCTION cdb_dataservices_server._cdb_tomtom_route_with_waypoints(
username TEXT,
orgname TEXT,
@@ -134,7 +135,7 @@ RETURNS cdb_dataservices_server.simple_route AS $$
import sys
service_manager.quota_service.increment_failed_service_use()
service_manager.logger.error('Error trying to calculate TomTom routing', sys.exc_info(), data={"username": username, "orgname": orgname})
raise Exception('Error trying to calculate TomTom routing')
raise Exception('Error trying to calculate TomTom routing: ' + str(e))
finally:
service_manager.quota_service.increment_total_service_use()
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;

View File

@@ -105,7 +105,7 @@ class MapboxIsolines():
elif response.status_code == requests.codes.unprocessable_entity:
return []
else:
raise ServiceException(response.status_code, response)
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
except requests.Timeout as te:
# In case of timeout we want to stop the job because the server
# could be down

View File

@@ -94,7 +94,7 @@ class MapboxRouting(Traceable):
elif response.status_code == requests.codes.unprocessable_entity:
return MapboxRoutingResponse(None, None, None)
else:
raise ServiceException(response.status_code, response)
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
except requests.Timeout as te:
# In case of timeout we want to stop the job because the server
# could be down

View File

@@ -82,7 +82,7 @@ class TomTomIsolines():
elif response.status_code == requests.codes.unprocessable_entity:
return []
else:
raise ServiceException(response.status_code, response)
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
except requests.Timeout as te:
# In case of timeout we want to stop the job because the server
# could be down

View File

@@ -120,7 +120,7 @@ class TomTomRouting(Traceable):
elif response.status_code == requests.codes.unprocessable_entity:
return TomTomRoutingResponse(None, None, None)
else:
raise ServiceException(response.status_code, response)
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
except requests.Timeout as te:
# In case of timeout we want to stop the job because the server
# could be down