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
'No suitable driver found' message when connection fails with nonexistent database #605
Comments
The problem with just bubbling up the second exception the is that if You say that "we're trying to concatenate error messages but that just doesn't work", could you explain why? I think the principle is sound, is there a reason it doesn't work in your particular case? I don't see concatenated error messages in your production mode example, but I'm not sure if that is because you just didn't include them, or maybe something else is chopping off exception messages at the first line feed. When I try with a bad database, I get the error messages concatenated:
It looks like the error message you get depends on the error in the connection string. The above example is with a bad host, but when I do it with a bad database I get:
I can see not concatenating the messages if they are identical, and possibly reordering the concatenation if the second exception message is usually better than the first, but dropping the concatenation entirely if the error messages are different just results in the loss of possibly useful information, so I'd be against that. |
How about the following?:
|
We aren't ever getting the messages concatenated. With edge Sequel, when we connect to a nonexistent database, we only get a single line error message. To illustrate, we added some puts statements in the rescues:
For some context, our use case is that users can register database servers and credentials and manage them through a web interface, and we're passing the error message to the front end. So we really don't want to show users the message that no suitable driver was found, if the actual error was that the database didn't exist. |
Also, is it expected for DriverManager.getConnection to fail? We are seeing it fail in production (with gems bundled with Jetpack) but not in development (where it's loaded using bundler). This is the same behavior reported in #477. |
I'm not sure why you aren't getting the error messages concatenated. As my example showed, the concatenation is happening in my environment. Can you figure out why the concatenation isn't working for you? DriverManager.getConnection can fail in certain cases, which is why Sequel has the fallback code it does. I think it may be a bug in JRuby, but it's been that way for a long time. Did you try the patch I posted, which gives priority to the e2 exception? |
Thanks for the information, your patch works for us. You're right about DriverManager getConnection, we found a JRuby bug report. http://jira.codehaus.org/browse/JRUBY-6372 We've looked a little at why the error messages aren't concatenated, beats me. We're on JRuby 1.7.0 using the jdbc-postgres gem. What's your environment? We're on jruby 1.7.0 and postgres-jdbc. |
I think I was testing on JRuby 1.6.8. Considering the exception changes in JRuby 1.7, it's possible the exception message concatenation is not working there. I'll see if I can figure out a work around for it, probably involving raising a new exception with the combined message instead of modifying the existing exception's message. |
We are using Sequel to connect to Greenplum (Postgres) database, and the error handling works perfectly in development (when we use the gem from Bundler).
In development, running the same code gives:
But in production mode (gems are bundled using Jetpack), we get an incorrect error message:
This seems to be related to #477, since the DriverManager's getConnection method is blowing up. (which is another kettle of fish)
However, the main problem is that the wrong error message is shown. In the JDBC adapter, we're trying to concatenate error messages but that just doesn't work. (cf https://github.com/jeremyevans/sequel/blob/master/lib/sequel/adapters/jdbc.rb#L240)
One possible fix is not catching the second error and just letting it bubble up.
The text was updated successfully, but these errors were encountered: