比如我下面的C++ API代码:
int main(int argc, char *argv[]) { DBConnection conn; bool ret = conn.connect("111.222.3.44", 8503); if(!ret){ cout<<"Failed to connect to the server"<<endl; return 0; } ConstantSP cmdVec = conn.run("add{a+b)");
run的DolphinDB脚本有点问题,在vs2017中执行后api程序就崩了,如下图:
DolphinDB API的处理问题的方式是抛出异常,因此需要try catch一下exception,比如:
try { ConstantSP cmdVec = conn.run("add{a+b)"); } catch (exception &ex) { cout << "Failed to run with error: " << ex.what(); return -1; }