From 4d14fb6922865fc6280bd5619eceab609b40994b Mon Sep 17 00:00:00 2001 From: Joshua Gilman Date: Fri, 3 May 2024 05:35:55 -0700 Subject: [PATCH] fix: prints connection errors for dbsync (#691) # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. Fixes # (issue) _if applicable_ ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Test A - [ ] Test B **Test Configuration**: _if applicable_ - Firmware version: - Hardware: - Toolchain: - SDK: **List of new dependencies**: _if applicable_ Provide a list of newly added dependencies in this PR, with the description of what are they doing and why do we need them. - Crate A: description - Crate B: description ## Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Co-authored-by: Oleksandr Prokhorenko --- .../ideascale-importer/ideascale_importer/db/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utilities/ideascale-importer/ideascale_importer/db/__init__.py b/utilities/ideascale-importer/ideascale_importer/db/__init__.py index 3692a6146e..58c89da9b6 100644 --- a/utilities/ideascale-importer/ideascale_importer/db/__init__.py +++ b/utilities/ideascale-importer/ideascale_importer/db/__init__.py @@ -219,12 +219,12 @@ async def connect(url: str, *args, **kwargs) -> asyncpg.Connection: """ try: conn = await asyncpg.connect(dsn=url, *args, **kwargs) - except Exception as _: - raise Exception("Database connection failed") + except Exception as e: + raise Exception(f"database connection failed: {e}") try: await conn.set_type_codec("jsonb", encoder=json.dumps, decoder=json.loads, schema="pg_catalog") - except Exception as _: - raise Exception("Failed to set jsonb codec") + except Exception as e: + raise Exception(f"failed to set jsonb codec: {e}") return conn