[PCBC-134] Provide more information on connection failure Created: 08/Oct/12  Updated: 26/Aug/13  Resolved: 26/Oct/12

Status: Resolved
Project: Couchbase PHP client library
Component/s: library
Affects Version/s: 1.1.0-dp4
Fix Version/s: 1.1.0
Security Level: Public

Type: Bug Priority: Major
Reporter: Dan Andersen Assignee: Michael Jackson
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates PCBC-58 Couchbase.so - constructing Couchbase... Resolved

 Description   
When you connect via the new Couchbase(...) is not a direct way to check for whether the connection failed.

It is not possible to check getResultCode()/getResultMessage() since this provides a unintilized couchbase

 Comments   
Comment by Mark Nunberg [ 08/Oct/12 ]
For this we'd probably need to change the ext code to return a valid couchbase object so that getResultCode can be called on it (to check for connection failures).

For the non-oo variant (couchbase_connect) behavior should remain the same (?)

Additionally, all the code which now checks for the couchbase object to simply exist should be changed to check that the couchbase object is indeed connected (I believe lcb has a function for that, but if not we can set our own little flag in our php_couchbase_ctx structure).

One workaround is to call set_error_handler and make it throw an ErrorException right before instantiation. Then the connection can be done in a try/catch block, with any message being found in $ex->getMessage().

I believe there may be ther workarounds as well
Comment by Michael Jackson [ 09/Oct/12 ]
patch set in progress: http://review.couchbase.org/#/c/21433/
Comment by Michael Jackson [ 09/Oct/12 ]
As a side note, I have a 1.0.x backport of the changes above ready to roll once the master branch changes are approved/merged.
Comment by Michael Jackson [ 10/Oct/12 ]
master branch changeset is merged in. 1.0.x changeset is here: http://review.couchbase.org/#/c/21487/
Comment by Michael Jackson [ 19/Oct/12 ]
(I believe all this needs for resolution is the 1.0.x changeset mentioned above to be merged into 1.0.x branch.)
Comment by Michael Jackson [ 26/Oct/12 ]
1.0.x merged in just now, 1.1 has been in for a bit. Should be present in next released versions.
Generated at Thu Aug 21 12:15:58 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.