diff --git a/server/extension/test/expected/50_namedplaces_test.out b/server/extension/test/expected/50_namedplaces_test.out index 6f18d8f..2e41285 100644 --- a/server/extension/test/expected/50_namedplaces_test.out +++ b/server/extension/test/expected/50_namedplaces_test.out @@ -1,21 +1,21 @@ -- Check that the public function is callable, even with no data -- It should return NULL SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ------------------------------ (1 row) SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Spain'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ------------------------------ (1 row) SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Valencia', 'Spain'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ------------------------------ @@ -35,42 +35,42 @@ INSERT INTO country_decoder (synonyms, iso2) VALUES (Array['spain', 'Spain'], 'E INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES'); -- This should return the point inserted above SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Spain'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche', 'Spain'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Valencia', 'Spain'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche', 'valencia', 'Spain'); -WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: (, ExternalRoutineException("spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.'",), ) +WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 diff --git a/server/lib/python/cartodb_services/cartodb_services/tools/log.py b/server/lib/python/cartodb_services/cartodb_services/tools/log.py index 817a423..500c8ab 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tools/log.py +++ b/server/lib/python/cartodb_services/cartodb_services/tools/log.py @@ -86,7 +86,14 @@ class Logger: self._file_logger.error(text, extra=extra_data) def _send_to_plpy(self, level, text, exception=None): - exception_message = '. Exception: {}'.format(str(exception)) if exception else '' + # exception might also be a tuple generated by sys.exc_info + if exception: + if isinstance(exception, tuple) and len(exception) > 1: + exception = exception[1] + exception_message = '. Exception: {}'.format(exception) + else: + exception_message = '' + message = '{}{}'.format(text, exception_message) if self._check_plpy(): if level == 'debug':