Refactor this function out, as we're doing the same thing twice.
Move handle_error into shared_cursor so the command cursor can use it too.
Fixed PHP-1046: Command cursor doesn't check if cursor exists.
Merged pull request #658