From 0e63a703edf77ec5fd9958dc8597bcab100d7d23 Mon Sep 17 00:00:00 2001 From: Andrey Kislyuk Date: Fri, 29 Dec 2023 09:39:06 -0800 Subject: [PATCH] Capture v2 errors --- aurora_data_api/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aurora_data_api/__init__.py b/aurora_data_api/__init__.py index b96710d..fbcf7bd 100644 --- a/aurora_data_api/__init__.py +++ b/aurora_data_api/__init__.py @@ -254,7 +254,7 @@ def _get_database_error(self, original_error): error = error_class(error_msg) error.response = getattr(original_error, "response", {}) return error - res = re.search(r"ERROR: .*\n Position: (\d+); SQLState: (\w+)$", error_msg) + res = re.search(r"ERROR: .*(?:\n |;) Position: (\d+); SQLState: (\w+)$", error_msg) if res: # PostgreSQL error error_code = res.group(2) error_class = PostgreSQLError.from_code(error_code) @@ -278,7 +278,7 @@ def execute(self, operation, parameters=None): if "columnMetadata" in res: self._set_description(res["columnMetadata"]) self._current_response = self._render_response(res) - except self._client.exceptions.BadRequestException as e: + except (self._client.exceptions.BadRequestException, self._client.exceptions.DatabaseErrorException) as e: if "Please paginate your query" in str(e): self._start_paginated_query(execute_statement_args) elif "Database returned more than the allowed response size limit" in str(e):