From 6a498498a67ffc5e23d7753001530f9b22ff2d50 Mon Sep 17 00:00:00 2001 From: Pat Nadolny Date: Wed, 2 Oct 2024 14:17:01 -0400 Subject: [PATCH] add title to error message if it exists --- tap_service_titan/client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tap_service_titan/client.py b/tap_service_titan/client.py index 0442aa9..d23f0ed 100644 --- a/tap_service_titan/client.py +++ b/tap_service_titan/client.py @@ -86,6 +86,23 @@ def parse_response(self, response: requests.Response) -> Iterable[dict]: """ yield from extract_jsonpath(self.records_jsonpath, input=response.json()) + def response_error_message(self, response: requests.Response) -> str: + """Build error message for invalid http statuses. + + WARNING - Override this method when the URL path may contain secrets or PII + + Args: + response: A :class:`requests.Response` object. + + Returns: + str: The error message + """ + default = super().response_error_message(response) + if "title" in response.json(): + title = response.json()["title"] + return f"{default}. {title}" + return default + class ServiceTitanExportStream(ServiceTitanBaseStream): """ServiceTitan stream class for export endpoints."""