Use JSTHROW* macros and fix coding style

Replace Nan::ThrowError by JSTHROW and Nan::ThrowTypeError by JSTHROW_TYPE.
This commit is contained in:
jspdown 2015-11-24 13:13:36 +01:00
parent 1d126caba5
commit 9b6c9a934c
2 changed files with 9 additions and 6 deletions

View File

@ -2,9 +2,12 @@ var cv = require('../lib/opencv');
// Load the image
cv.readImage('./files/note.png', function(err, im) {
console.log('plop');
if (err) { throw err; }
if (im.width() < 1 || im.height() < 1) { throw new Error('Image has no size'); }
if (err) {
throw err;
}
if (im.width() < 1 || im.height() < 1) {
throw new Error('Image has no size');
}
im.cvtColor('CV_BGR2GRAY');
var bw = im.adaptiveThreshold(255, 0, 0, 15, 2);

View File

@ -172,14 +172,14 @@ NAN_METHOD(ImgProc::GetStructuringElement) {
// Arg 0 is the element shape
if (!info[0]->IsNumber()) {
Nan::ThrowTypeError("'shape' argument must be a number");
JSTHROW_TYPE("'shape' argument must be a number");
}
int shape = info[0]->NumberValue();
// Arg 1 is the size of the structuring element
cv::Size ksize;
if (!info[1]->IsArray()) {
Nan::ThrowTypeError("'ksize' argument must be a 2 double array");
JSTHROW_TYPE("'ksize' argument must be a 2 double array");
}
Local<Object> v8sz = info[1]->ToObject();
ksize = cv::Size(v8sz->Get(0)->IntegerValue(), v8sz->Get(1)->IntegerValue());
@ -196,7 +196,7 @@ NAN_METHOD(ImgProc::GetStructuringElement) {
info.GetReturnValue().Set(outMatrixWrap);
} catch (cv::Exception &e) {
const char *err_msg = e.what();
Nan::ThrowError(err_msg);
JSTHROW(err_msg);
return;
}
}