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

Add exception cause support to PoolResourceLost and ConnectionLost constructors #199

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

lachlan
Copy link
Contributor

@lachlan lachlan commented Nov 30, 2023

Implementing database drivers are required to raise a ConnectionLost error when they detect an existing connection has gone bad (such as when a firewall or server resets the connection). However the original exception (probably IO::Error) is lost. I'd really like to be able to see the original exception (and especially it's stack trace) which caused the ConnectionLost error to be thrown, because it will help diagnose / investigate whatever caused the issue (i.e. it could be caused by a defect in the database driver, rather than a true bad connection).

This pull request updates the PoolResourceLost (and is inherited to ConnectionLost) constructor to add the missing optional cause parameter that is available on the base Exception class.

Obviously then it will be up to the database drivers to include the cause when raising ConnectionLost.

Thanks for your consideration!

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bcardiff bcardiff merged commit 06df272 into crystal-lang:master Nov 30, 2023
6 checks passed
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