Search code examples
cassandradatastax

Why does cass_future_get_result() return NULL?


I'm using Datastax C++ driver. Intermittently I've noticed that cass_future_get_result() will return a NULL pointer.

The documentation says that NULL will be returned in case of an error. (http://datastax.github.io/cpp-driver/api/struct.CassFuture/) That's ambiguous to the point of being unhelpful.

What are the errors that will cause it to return NULL?


Solution

  • To get more information about the error you can perform the following:

    CassError error_code = cass_future_error_code(future);
    const char* error_message;
    size_t error_message_length;
    cass_future_error_message(future, &error_message, &error_message_length);
    fprintf(stderr, "Error: %s\nError Message %.*s\n",
                    cass_error_desc(error_code),
                    (int)error_message_length,
                    error_message);