File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
core/include/opencv2/core Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 8
8
#include < opencv2/core/async.hpp>
9
9
#include < opencv2/core/detail/async_promise.hpp>
10
10
11
+ #include < stdexcept>
12
+
11
13
namespace cv { namespace utils {
12
14
// ! @addtogroup core_utils
13
15
// ! @{
@@ -113,6 +115,12 @@ String dumpRange(const Range& argument)
113
115
}
114
116
}
115
117
118
+ CV_WRAP static inline
119
+ void testRaiseGeneralException ()
120
+ {
121
+ throw std::runtime_error (" exception text" );
122
+ }
123
+
116
124
CV_WRAP static inline
117
125
AsyncArray testAsyncArray (InputArray argument)
118
126
{
Original file line number Diff line number Diff line change @@ -206,6 +206,11 @@ catch (const cv::Exception &e) \
206
206
{ \
207
207
pyRaiseCVException (e); \
208
208
return 0 ; \
209
+ } \
210
+ catch (const std::exception &e) \
211
+ { \
212
+ PyErr_SetString (opencv_error, e.what ()); \
213
+ return 0 ; \
209
214
}
210
215
211
216
using namespace cv ;
Original file line number Diff line number Diff line change @@ -47,6 +47,12 @@ def test_inheritance(self):
47
47
boost .getMaxDepth () # from ml::DTrees
48
48
boost .isClassifier () # from ml::StatModel
49
49
50
+ def test_raiseGeneralException (self ):
51
+ with self .assertRaises ((cv .error ,),
52
+ msg = 'C++ exception is not propagated to Python in the right way' ) as cm :
53
+ cv .utils .testRaiseGeneralException ()
54
+ self .assertEqual (str (cm .exception ), 'exception text' )
55
+
50
56
def test_redirectError (self ):
51
57
try :
52
58
cv .imshow ("" , None ) # This causes an assert
You can’t perform that action at this time.
0 commit comments