IResponsePtr RpcMethods::Post(const std::string& req) { JsonRpcRequest request; IResponsePtr response; string id = ""; try{ request.Deserialize(req); id = request.GetId(); auto method = request.GetMethod(); if(this->paths.find(method) == this->paths.end()) response = make_shared<ErrorJsonRpcResponse>(-32601,"Method does not exist",id); else response = make_shared<ValidJsonRpcResponse>(this->paths[method]->Execute(request.GetParams()),id); } catch(const DataStoreException& ex) { response = make_shared<ErrorJsonRpcResponse>(-32603,ex.what(), id); } catch(const std::exception& ex) { response = make_shared<ErrorJsonRpcResponse>(-32600,ex.what(),id); } return response; }