Skip to content

Commit

Permalink
fix: prints connection errors for dbsync (#691)
Browse files Browse the repository at this point in the history
# 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 <djminikin@gmail.com>
  • Loading branch information
jmgilman and minikin authored May 3, 2024
1 parent 317d2d4 commit 4d14fb6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4d14fb6

Please sign in to comment.