From 88da7ce9977acdc96df4bb75c5c4a5a83b121a1d Mon Sep 17 00:00:00 2001 From: Staci Cooper Date: Tue, 12 Sep 2023 11:45:08 -0700 Subject: [PATCH] Add function name to logs for easier debugging --- catalog/dags/common/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/catalog/dags/common/utils.py b/catalog/dags/common/utils.py index 755a42429fd..aa6f238b1b8 100644 --- a/catalog/dags/common/utils.py +++ b/catalog/dags/common/utils.py @@ -44,7 +44,8 @@ def wrap(func: callable) -> callable: media_type := signature(func).parameters.get("media_type") ) is None or media_type.kind != _ParameterKind.KEYWORD_ONLY: raise Exception( - "Improperly configured: `media_type` must be a keyword-only argument" + f"Improperly configured function `{func.__qualname__}`:" + " `media_type` must be a keyword-only argument." ) @functools.wraps(func) @@ -57,7 +58,10 @@ def wrapped(*args, **kwargs): media_type = kwargs.get("media_type", None) if media_type not in values_by_media_type.keys(): - raise ValueError(f"No values matching media type: {media_type}") + raise ValueError( + f"{func.__qualname__}: No values matching media type" + f" `{media_type}`" + ) # Get the value corresponding to the media type media_info = values_by_media_type.get(media_type)