From 901edf4d5866c65f996e27d49f8cf9cdbd3d17e4 Mon Sep 17 00:00:00 2001 From: Adrian Sieber Date: Thu, 8 Oct 2015 21:43:36 +0200 Subject: [PATCH] Throw error if invalid binarization technique is provided --- src/Matrix.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Matrix.cc b/src/Matrix.cc index bc5f64f..8af505d 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -1,6 +1,7 @@ #include "Contours.h" #include "Matrix.h" #include "OpenCV.h" +#include #include Nan::Persistent Matrix::constructor; @@ -1652,6 +1653,19 @@ NAN_METHOD(Matrix::Threshold) { else if (strcmp(*typstr, "Threshold to Zero Inverted") == 0) { typ = 4; } + else { + char *typeString = *typstr; + char text[] = "\" is no supported binarization technique. " + "Use \"Binary\", \"Binary Inverted\", \"Threshold Truncated\", " + "\"Threshold to Zero\" or \"Threshold to Zero Inverted\""; + char errorMessage[strlen(typeString) + strlen(text) + 2]; + strcpy(errorMessage, "\""); + strcat(errorMessage, typeString); + strcat(errorMessage, text); + + Nan::ThrowError(errorMessage); + return; + } } Local < Object > img_to_return =