Description

The code breaks abruptly when connection URI is not given in a proper format in the SDK client for connecting the to required Couchbase server.
For instance, when I am specifying the URI as "http:/10.3.2.57:8091/index.html" instead of "http:/10.3.2.57:8091/pools", exception appears,
whereas a proper error message should be returned saying that 'Connection could not be established to the requested server location'.
Please find attached the log file for the exception trace.

Activity

I think the logs already provide a helpful error message with the stack trace that shows what it tried to parse.

In the case you provided, the logs would say 2012-11-08 10:29:09.254 WARN com.couchbase.client.vbucket.ConfigurationProviderHTTP: Provided URI http://192.168.1.105:8091/index.html has an unparsable response...skipping

and then print a stack trace of what was tried to parse (in this case hughe chunks of HTML).

Also, if you pass in more URIs it would try to get the next one to establish a successful connection.

I think we could catch it and add a different error message, but then it wont be clear to the user what happened.

If you think we really should change something here, please reopen the issue and then we can discuss it together at a broader audience!

Michael Nitschinger
added a comment - 08/Nov/12 3:33 AM Deepti,
I think the logs already provide a helpful error message with the stack trace that shows what it tried to parse.
In the case you provided, the logs would say 2012-11-08 10:29:09.254 WARN com.couchbase.client.vbucket.ConfigurationProviderHTTP: Provided URI http://192.168.1.105:8091/index.html has an unparsable response...skipping
and then print a stack trace of what was tried to parse (in this case hughe chunks of HTML).
Also, if you pass in more URIs it would try to get the next one to establish a successful connection.
I think we could catch it and add a different error message, but then it wont be clear to the user what happened.
If you think we really should change something here, please reopen the issue and then we can discuss it together at a broader audience!
Thanks,
Michael

As discussed with you, I think the exception here should be caught in a very generic manner that gives the user some information like this - "Connection could not be established - Either the URI provided is incorrect or the host is unavailable". As the user is not concerned about what is happening beyond the scene and not in the least about what is getting parsed in order for the connection to be established. He is just concerned about the system URL he wants to connect to and the network. Either of these two if unavailable with cause an issue in connection, only that needs to be highlighted back to the user in form of a warning message. It should not abruptly break the code. Hence, I am reopening this defect for further investigation.

Deepti Dawar
added a comment - 08/Nov/12 4:44 AM Dear Michael,
As discussed with you, I think the exception here should be caught in a very generic manner that gives the user some information like this - "Connection could not be established - Either the URI provided is incorrect or the host is unavailable". As the user is not concerned about what is happening beyond the scene and not in the least about what is getting parsed in order for the connection to be established. He is just concerned about the system URL he wants to connect to and the network. Either of these two if unavailable with cause an issue in connection, only that needs to be highlighted back to the user in form of a warning message. It should not abruptly break the code. Hence, I am reopening this defect for further investigation.
Regards,
Deepti

Deepti Dawar
added a comment - 08/Jan/13 9:22 AM Mark, can we have any exceptions like DisplayableException which could be shown to the end user ?
Can you please give details about the connection or execution exceptions.

What is displayed to the user is a sub-component of logging and not of the exception itself. An exception is not an exception unless it represents an exceptional condition; it is up to the code catching the exception to convert this to something the user can understand.

I am not sure if the Couchbase Java client has classes for "connection" exceptions which indicate a difficulty in communication between client and server, but if there isn't such a class then it should be created.

Theroetically

class CouchbaseConnectionException extends Exception

{
....
}

Typically it seems most of the Couchbase exceptions in the Java client are RuntimeExceptions or ExecutionExceptions (i.e. generic "unchecked" exceptions).

Matt and Michale might have more knowledge of the various classes contained therein and their suitability of use.

Mark Nunberg
added a comment - 08/Jan/13 12:12 PM What is displayed to the user is a sub-component of logging and not of the exception itself. An exception is not an exception unless it represents an exceptional condition; it is up to the code catching the exception to convert this to something the user can understand.
I am not sure if the Couchbase Java client has classes for "connection" exceptions which indicate a difficulty in communication between client and server, but if there isn't such a class then it should be created.
Theroetically
class CouchbaseConnectionException extends Exception
{
....
}
Typically it seems most of the Couchbase exceptions in the Java client are RuntimeExceptions or ExecutionExceptions (i.e. generic "unchecked" exceptions).
Matt and Michale might have more knowledge of the various classes contained therein and their suitability of use.

I agree. There should be in-house exception classes meant to facilitate this purpose.
A user working with couchbase sdk, should have the feasibility of using those exception classes for understanding various scenarios and then acting accordingly.

Please let us know if there are any exception classes for communicating the connection exception to the user in which we can embed a custom message stating what happened.

Deepti Dawar
added a comment - 09/Jan/13 5:02 AM - edited I agree. There should be in-house exception classes meant to facilitate this purpose.
A user working with couchbase sdk, should have the feasibility of using those exception classes for understanding various scenarios and then acting accordingly.
Please let us know if there are any exception classes for communicating the connection exception to the user in which we can embed a custom message stating what happened.