From 4cdf19f3a95d460046236bd31afcf92cc03cee82 Mon Sep 17 00:00:00 2001 From: fmigneault Date: Fri, 3 Dec 2021 12:06:03 -0500 Subject: [PATCH] add log entry to investigate failing service creation (relates to https://github.com/bird-house/birdhouse-deploy/pull/224#issuecomment-985668339) --- magpie/services.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/magpie/services.py b/magpie/services.py index 294d7171d..8901d3b63 100644 --- a/magpie/services.py +++ b/magpie/services.py @@ -973,14 +973,23 @@ def service_factory(service, request): """ ax.verify_param(service, param_compare=models.Service, is_type=True, http_error=HTTPBadRequest, content={"service": repr(service)}, - msg_on_fail="Cannot process invalid service object") + msg_on_fail="Cannot process invalid service object.") service_type = ax.evaluate_call(lambda: service.type, http_error=HTTPInternalServerError, - msg_on_fail="Cannot retrieve service type from object") + msg_on_fail="Cannot retrieve service type from object.") ax.verify_param(service_type, is_in=True, param_compare=SERVICE_TYPE_DICT.keys(), http_error=HTTPNotImplemented, content={"service_type": service_type}, - msg_on_fail="Undefined service type mapping to service object") - return ax.evaluate_call(lambda: SERVICE_TYPE_DICT[service_type](service, request), - http_error=HTTPInternalServerError, + msg_on_fail="Undefined service type mapping to service object.") + + def _make_service(_typ, _svc, _req): + try: + return SERVICE_TYPE_DICT[_typ](_svc, _req) + except Exception as exc: + LOGGER.debug("Failed service creation using (type [%s], service [%s], request [%s]). Exception: [%s] (%s).", + _typ, _svc, _req, type(exc).__name__, exc, exc_info=exc) + raise + + return ax.evaluate_call(lambda: _make_service(service_type, service, request), + http_error=HTTPInternalServerError, content={"service_type": service_type}, msg_on_fail="Failed to find requested service type.")