Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit dd3654a

Browse files
Merge pull request justadudewhohacks#439 from oyyd/fix-return
src: return when throwing errors
2 parents 315767d + a619756 commit dd3654a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

cc/core/Mat.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ NAN_METHOD(Mat::GetDataAsArray) {
326326

327327
NAN_METHOD(Mat::GetRegion) {
328328
if (!FF_IS_INSTANCE(Rect::constructor, info[0])) {
329-
Nan::ThrowError("Mat::GetRegion expected arg0 to be an instance of Rect");
329+
return Nan::ThrowError("Mat::GetRegion expected arg0 to be an instance of Rect");
330330
}
331331
cv::Rect2d rect = FF_UNWRAP(info[0]->ToObject(), Rect)->rect;
332332
FF_OBJ jsRegion = FF_NEW_INSTANCE(constructor);

test/tests/core/Mat/Mat.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,5 +980,17 @@ describe('Mat', () => {
980980
describe('Row average', makeTest(1, cv.REDUCE_AVG, cv.CV_32F, [ [ 1 ] ]));
981981
describe('Row max', makeTest(1, cv.REDUCE_MAX, -1, [ [ 1 ] ]));
982982
describe('Row min', makeTest(1, cv.REDUCE_MIN, -1, [ [ 1 ] ]));
983-
})
983+
});
984+
985+
describe('checking of non-instance arguments', () => {
986+
it('should throw errors with correct error '
987+
+ 'messages with non-instance arguments', () => {
988+
const img = getTestImg().bgrToGray();
989+
990+
assertError(
991+
() => img.getRegion(0, 1, 2, 3),
992+
'Error: Mat::GetRegion expected arg0 to be an instance of Rect'
993+
);
994+
});
995+
});
984996
});

0 commit comments

Comments
 (0)