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

Already on GitHub? Sign in to your account

Make exception message more friendly #69

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

I've met a exception such as "not talking to master and retries used up,error from server",but i don't know why.
At last,i found it that because i query data from secondary mongodb not master,so i have to set slaveOk to be true.

But if the exception message contained server error message,i can fixed it much more easily.So i pull this request to add server error in exception message.Thanks a lot.

It would be perhaps even better to include some tips how to fix the problem? F.ex. if the problem is that the driver is talking to a slave and hasn't been allowed to do so then the exception should tip the user about it:

"Connected to a slave Mongo instance but (reading from|writting to) a slave isn't allowed (set slaveOK if you want to allow it.) " +

@jakubholynet
Much better if you can give some tips about the problem.But i don't know if there are other situations exists that make this exception happen except set slaveOK to be true.

If we have some tips is better,but i think the driver at here should not eat the error message from the server.

@ghost ghost assigned breinero Aug 30, 2012

Contributor

trishagee commented Jul 2, 2013

Hi, sorry for the extreme delay in responding to this issue. I agree that Exception messages in the Java driver are less than optimal, however for the 3.x driver we're changing all the exceptions across the board, hopefully with more useful information. We'd rather not change Exceptions individually in the existing driver (like this pull request) but implement an overall strategy that should address all exceptions.

@trishagee trishagee closed this Jul 2, 2013

@trishagee going over all the exceptions is a great strategy! however, in the meantime, this causes a lot of pain and the pull request would be a nice stop gap. this doesn't change the exception type, but only adds useful missing information to the exception message, so i don't see the downside

Contributor

trishagee commented Jul 3, 2013

I agree, however we anticipate that the next release of the current driver will only contain defect fixes. Although this pull request is a small change, because of the existing limitations with exceptions it's likely that users are actually parsing Exception message Strings to figure out what's going on, so any change to exception messages might actually break people's code. Technically the change doesn't break backwards compatibility, but it could have an impact, and it's not a chance we want to take with the existing driver right now.

If we do make an update to the driver that's not just defects, then we'll consider adding this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment