src/n1ql.c
/* note that the analytics and query error contexts are identical -- could
   make a clever macro solution to DRY this up, but then I'd never be able to
   understand it again.  So, no. Maybe later.
   */
note that the analytics and query error contexts are identical -- could
make a clever macro solution to DRY this up, but then I'd never be able to
understand it again.  So, no. Maybe later.
note that the analytics and query error contexts are identical -- could make a clever macro solution to DRY this up but then I ' d never be able to understand it again . So no . Maybe later .
void convert_analytics_error_context(const lcb_ANALYTICS_ERROR_CONTEXT* ctx,
                                     pycbc_MultiResult *mres) {
    pycbc_enhanced_err_info* err_info = PyDict_New();
    PyObject* err_context = PyDict_New();
    PyDict_SetItemString(err_info, "error_context", err_context);
    if (ctx) {
        uint32_t uint32_val;
        const char* val;
        size_t len;
        lcb_errctx_analytics_first_error_code(ctx, &uint32_val);
        pycbc_set_kv_ull_str(err_context, "first_error_code", (lcb_uint64_t)uint32_val);
        lcb_errctx_analytics_http_response_code(ctx, &uint32_val);
        pycbc_set_kv_ull_str(err_context, "http_response_code", (lcb_uint64_t)uint32_val);
        lcb_errctx_analytics_first_error_message(ctx, &val, &len);
        pycbc_dict_add_text_kv_strn2(err_context, "first_error_message", val, len);
        lcb_errctx_analytics_statement(ctx, &val, &len);
        pycbc_dict_add_text_kv_strn2(err_context, "statement", val, len);
        lcb_errctx_analytics_client_context_id(ctx, &val, &len);
        pycbc_dict_add_text_kv_strn2(err_context, "client_context_id", val, len);
        lcb_errctx_analytics_query_params(ctx, &val, &len);
        pycbc_dict_add_text_kv_strn2(err_context, "query_params", val, len);
        lcb_errctx_analytics_http_response_body(ctx, &val, &len);
        pycbc_dict_add_text_kv_strn2(err_context, "http_response_body", val, len);
        lcb_errctx_analytics_endpoint(ctx, &val, &len);
        pycbc_dict_add_text_kv_strn2(err_context, "endpoint", val, len);
        pycbc_dict_add_text_kv(err_context, "type", "AnalyticsErrorContext");
    }
    mres->err_info = err_info;
    Py_DECREF(err_context);
}
void convert_analytics_error_context ( const lcb_ANALYTICS_ERROR_CONTEXT * ctx , pycbc_MultiResult * mres ) { pycbc_enhanced_err_info * err_info = PyDict_New ( ) ; PyObject * err_context = PyDict_New ( ) ; PyDict_SetItemString ( err_info , " " , err_context ) ; if ( ctx ) { uint32_t uint32_val ; const char * val ; size_t len ; lcb_errctx_analytics_first_error_code ( ctx , & uint32_val ) ; pycbc_set_kv_ull_str ( err_context , " " , ( lcb_uint64_t ) uint32_val ) ; lcb_errctx_analytics_http_response_code ( ctx , & uint32_val ) ; pycbc_set_kv_ull_str ( err_context , " " , ( lcb_uint64_t ) uint32_val ) ; lcb_errctx_analytics_first_error_message ( ctx , & val , & len ) ; pycbc_dict_add_text_kv_strn2 ( err_context , " " , val , len ) ; lcb_errctx_analytics_statement ( ctx , & val , & len ) ; pycbc_dict_add_text_kv_strn2 ( err_context , " " , val , len ) ; lcb_errctx_analytics_client_context_id ( ctx , & val , & len ) ; pycbc_dict_add_text_kv_strn2 ( err_context , " " , val , len ) ; lcb_errctx_analytics_query_params ( ctx , & val , & len ) ; pycbc_dict_add_text_kv_strn2 ( err_context , " " , val , len ) ; lcb_errctx_analytics_http_response_body ( ctx , & val , & len ) ; pycbc_dict_add_text_kv_strn2 ( err_context , " " , val , len ) ; lcb_errctx_analytics_endpoint ( ctx , & val , & len ) ; pycbc_dict_add_text_kv_strn2 ( err_context , " " , val , len ) ; pycbc_dict_add_text_kv ( err_context , " " , " " ) ; } mres -> err_info = err_info ; Py_DECREF ( err_context ) ; }
note that the analytics and query error contexts are identical -- could
make a clever macro solution to DRY this up, but then I'd never be able to
understand it again.
note that the analytics and query error contexts are identical -- could make a clever macro solution to DRY this up but then I ' d never be able to understand it again .