From 08f14a00aa9b1627a31a94738eafaf82b3ae6bfd Mon Sep 17 00:00:00 2001 From: Shivam Raj <171748731+shivam2680@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:33:50 +0530 Subject: [PATCH] [PECO-1961] On non-retryable error, ensure PySQL includes useful information in error (#447) * added error info on non-retryable error --- src/databricks/sql/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/databricks/sql/utils.py b/src/databricks/sql/utils.py index 97df6d4d..ffeaeaf0 100644 --- a/src/databricks/sql/utils.py +++ b/src/databricks/sql/utils.py @@ -31,6 +31,7 @@ import logging BIT_MASKS = [1, 2, 4, 8, 16, 32, 64, 128] +DEFAULT_ERROR_CONTEXT = "Unknown error" logger = logging.getLogger(__name__) @@ -407,7 +408,12 @@ def user_friendly_error_message(self, no_retry_reason, attempt, elapsed): user_friendly_error_message = "{}: {}".format( user_friendly_error_message, self.error_message ) - return user_friendly_error_message + try: + error_context = str(self.error) + except: + error_context = DEFAULT_ERROR_CONTEXT + + return user_friendly_error_message + ". " + error_context # Taken from PyHive