Gracefully handle errors

Change-Id: Idf0459787867d5d8acb75b0fabf5ae64406cc7c7
Reviewed-on: http://review.couchbase.org/35943
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>