wrap turns exceptions into MATLAB errors
							parent
							
								
									dd34792e7e
								
							
						
					
					
						commit
						cf4a4b4285
					
				| 
						 | 
					@ -481,6 +481,7 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co
 | 
				
			||||||
		file.oss << "  std::streambuf *outbuf = std::cout.rdbuf(&mout);\n\n";
 | 
							file.oss << "  std::streambuf *outbuf = std::cout.rdbuf(&mout);\n\n";
 | 
				
			||||||
		file.oss << "  _" << name << "_RTTIRegister();\n\n";
 | 
							file.oss << "  _" << name << "_RTTIRegister();\n\n";
 | 
				
			||||||
		file.oss << "  int id = unwrap<int>(in[0]);\n\n";
 | 
							file.oss << "  int id = unwrap<int>(in[0]);\n\n";
 | 
				
			||||||
 | 
							file.oss << "  try {\n";
 | 
				
			||||||
		file.oss << "    switch(id) {\n";
 | 
							file.oss << "    switch(id) {\n";
 | 
				
			||||||
		for(size_t id = 0; id < functionNames.size(); ++id) {
 | 
							for(size_t id = 0; id < functionNames.size(); ++id) {
 | 
				
			||||||
			file.oss << "    case " << id << ":\n";
 | 
								file.oss << "    case " << id << ":\n";
 | 
				
			||||||
| 
						 | 
					@ -488,6 +489,9 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co
 | 
				
			||||||
			file.oss << "      break;\n";
 | 
								file.oss << "      break;\n";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		file.oss << "    }\n";
 | 
							file.oss << "    }\n";
 | 
				
			||||||
 | 
							file.oss << "  } catch(const std::exception& e) {\n";
 | 
				
			||||||
 | 
							file.oss << "    mexErrMsgTxt((\"Exception from gtsam:\\n\" + std::string(e.what()) + \"\\n\").c_str());\n";
 | 
				
			||||||
 | 
							file.oss << "  }\n";
 | 
				
			||||||
		file.oss << "\n";
 | 
							file.oss << "\n";
 | 
				
			||||||
		file.oss << "  std::cout.rdbuf(outbuf);\n"; // Restore cout
 | 
							file.oss << "  std::cout.rdbuf(outbuf);\n"; // Restore cout
 | 
				
			||||||
		file.oss << "}\n";
 | 
							file.oss << "}\n";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue