Skip to content

Commit

Permalink
Don’t continue execution when error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicdoe committed Mar 10, 2017
1 parent 42487dc commit 2e3aa33
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions icuWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ NAN_METHOD(DetectCharacterEncoding) {

if(U_FAILURE(errorCode)) {
Nan::ThrowError("Failed to open ICU charset detector.");
return;
}

ucsdet_setText(
Expand All @@ -27,24 +28,28 @@ NAN_METHOD(DetectCharacterEncoding) {

if(U_FAILURE(errorCode)) {
Nan::ThrowError("Failed to set ICU charset detector’s text.");
return;
}

charsetMatch = ucsdet_detect(charsetDetector, &errorCode);

if(U_FAILURE(errorCode)) {
Nan::ThrowError("Failed to detect charset.");
return;
}

const char *charsetName = ucsdet_getName(charsetMatch, &errorCode);

if(U_FAILURE(errorCode)) {
Nan::ThrowError("Failed to get name from charset match.");
return;
}

int32_t confidence = ucsdet_getConfidence(charsetMatch, &errorCode);

if(U_FAILURE(errorCode)) {
Nan::ThrowError("Failed to get confidence from charset match.");
return;
}

v8::Local<v8::Object> obj = Nan::New<v8::Object>();
Expand Down

0 comments on commit 2e3aa33

Please sign in to comment.