Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add error handling for database connection #34

Merged

Conversation

Ptradtya26
Copy link
Contributor

Summary

Adds error handling for database connections in the DB class in examples/visualizer/main.py.
Validates the presence of the CHAI_DATABASE_URL environment variable before attempting a connection.
Wraps the psycopg2.connect call in a try-except block to provide meaningful error messages when a connection fails.

Why This Change is Necessary

Prevents unexpected crashes when the database connection fails or CHAI_DATABASE_URL is not set.
Provides clear, actionable feedback to the user.

Changes

Added a validation step for CHAI_DATABASE_URL.
Added error handling for psycopg2.OperationalError during database connection.

@sanchitram1 sanchitram1 merged commit 8588e71 into teaxyz:main Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants