Server: Better error handling and provide error details
This commit is contained in:
@@ -66,11 +66,12 @@ RETURNS cdb_dataservices_server.simple_route AS $$
|
|||||||
import sys
|
import sys
|
||||||
service_manager.quota_service.increment_failed_service_use()
|
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})
|
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:
|
finally:
|
||||||
service_manager.quota_service.increment_total_service_use()
|
service_manager.quota_service.increment_total_service_use()
|
||||||
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server._cdb_tomtom_route_with_waypoints(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._cdb_tomtom_route_with_waypoints(
|
||||||
username TEXT,
|
username TEXT,
|
||||||
orgname TEXT,
|
orgname TEXT,
|
||||||
@@ -134,7 +135,7 @@ RETURNS cdb_dataservices_server.simple_route AS $$
|
|||||||
import sys
|
import sys
|
||||||
service_manager.quota_service.increment_failed_service_use()
|
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})
|
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:
|
finally:
|
||||||
service_manager.quota_service.increment_total_service_use()
|
service_manager.quota_service.increment_total_service_use()
|
||||||
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class MapboxIsolines():
|
|||||||
elif response.status_code == requests.codes.unprocessable_entity:
|
elif response.status_code == requests.codes.unprocessable_entity:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
raise ServiceException(response.status_code, response)
|
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
# In case of timeout we want to stop the job because the server
|
# In case of timeout we want to stop the job because the server
|
||||||
# could be down
|
# could be down
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class MapboxRouting(Traceable):
|
|||||||
elif response.status_code == requests.codes.unprocessable_entity:
|
elif response.status_code == requests.codes.unprocessable_entity:
|
||||||
return MapboxRoutingResponse(None, None, None)
|
return MapboxRoutingResponse(None, None, None)
|
||||||
else:
|
else:
|
||||||
raise ServiceException(response.status_code, response)
|
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
# In case of timeout we want to stop the job because the server
|
# In case of timeout we want to stop the job because the server
|
||||||
# could be down
|
# could be down
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class TomTomIsolines():
|
|||||||
elif response.status_code == requests.codes.unprocessable_entity:
|
elif response.status_code == requests.codes.unprocessable_entity:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
raise ServiceException(response.status_code, response)
|
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
# In case of timeout we want to stop the job because the server
|
# In case of timeout we want to stop the job because the server
|
||||||
# could be down
|
# could be down
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class TomTomRouting(Traceable):
|
|||||||
elif response.status_code == requests.codes.unprocessable_entity:
|
elif response.status_code == requests.codes.unprocessable_entity:
|
||||||
return TomTomRoutingResponse(None, None, None)
|
return TomTomRoutingResponse(None, None, None)
|
||||||
else:
|
else:
|
||||||
raise ServiceException(response.status_code, response)
|
raise ServiceException('Unexpected response (' + str(response.status_code) + '): ' + str(response.content), response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
# In case of timeout we want to stop the job because the server
|
# In case of timeout we want to stop the job because the server
|
||||||
# could be down
|
# could be down
|
||||||
|
|||||||
Reference in New Issue
Block a user