Improved exception handling and unit tests

This commit is contained in:
hbristow
2013-06-19 16:37:57 +10:00
parent bbece095fb
commit 0c726a3fbe
4 changed files with 46 additions and 2 deletions

View File

@@ -27,6 +27,16 @@ std::vector<Bridge> {{function.name}}({{clss.name}}& inst, const std::vector<Bri
// setup
// invoke
try {
// invoke
} catch(cv::Exception& e) {
mexErrMsgTxt(std::string("cv::exception caught: ").append(e.what()).c_str());
} catch(std::exception& e) {
mexErrMsgTxt(std::string("std::exception caught: ").append(e.what()).c_str());
} catch(...) {
mexErrMsgTxt("Uncaught exception occurred in {{fun.name}}");
}
// setdown
}

View File

@@ -11,6 +11,7 @@
#include "bridge.hpp"
#include <string>
#include <vector>
#include <exception>
#include <opencv2/core.hpp>
{% block includes %}
{% endblock %}
@@ -42,7 +43,9 @@ void mexFunction(int nlhs, mxArray* plhs[],
try {
{{fun.name}}();
} catch(cv::Exception& e) {
mexErrMsgTxt(std::string("OpenCV exception caught: ").append(e.what()).c_str());
mexErrMsgTxt(std::string("cv::exception caught: ").append(e.what()).c_str());
} catch(std::exception& e) {
mexErrMsgTxt(std::string("std::exception caught: ").append(e.what()).c_str());
} catch(...) {
mexErrMsgTxt("Uncaught exception occurred in {{fun.name}}");
}