[ML] Change InvalidValuesError to TypeMismatchError for no args 59/255059/1
authorRafal Walczyna <r.walczyna@samsung.com>
Thu, 11 Mar 2021 14:06:57 +0000 (15:06 +0100)
committerRafal Walczyna <r.walczyna@samsung.com>
Thu, 11 Mar 2021 14:09:44 +0000 (15:09 +0100)
When function is called without args, converter throws TypeError.
This commit unifies it.

code_format has been also applied.

[Verification] Builts successful, tested in chrome console

Change-Id: I032fd3f78e06b561ae472cdbbafe3bcf4092a6d9
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
src/ml/js/ml_common.js
src/ml/js/ml_pipeline.js
src/ml/js/ml_single.js
src/ml/ut/main.cc

index cb863c8..e38f097 100755 (executable)
@@ -164,7 +164,7 @@ TensorsData.prototype.getTensorRawData = function() {
 
     if (!args.has.index) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: index is undefined'
         );
     }
@@ -474,7 +474,7 @@ TensorsInfo.prototype.getDimensions = function() {
 
     if (!args.has.index) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: index is undefined'
         );
     }
@@ -546,7 +546,7 @@ TensorsInfo.prototype.getTensorName = function() {
 
     if (!args.has.index) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: index is undefined'
         );
     }
@@ -583,14 +583,14 @@ TensorsInfo.prototype.setTensorName = function() {
 
     if (!args.has.index) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: index is undefined'
         );
     }
 
     if (!args.has.name) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: name is undefined'
         );
     }
@@ -623,7 +623,7 @@ TensorsInfo.prototype.getTensorType = function() {
 
     if (!args.has.index) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: index is undefined'
         );
     }
@@ -694,7 +694,7 @@ TensorsInfo.prototype.getTensorSize = function() {
 
     if (!args.has.index) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: index is undefined'
         );
     }
index f9a285f..5f29c51 100755 (executable)
@@ -51,7 +51,7 @@ var CreatePipeline = function() {
 
     if (!args.has.definition) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: pipeline definition is mandatory'
         );
     }
@@ -258,7 +258,7 @@ Pipeline.prototype.getSource = function() {
 
     if (!args.has.name) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: name is mandatory'
         );
     }
@@ -462,7 +462,7 @@ Pipeline.prototype.unregisterSinkListener = function() {
 
     if (!args.has.name) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: sink name is mandatory'
         );
     }
@@ -661,7 +661,7 @@ Switch.prototype.select = function() {
 
     if (!args.has.padName) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: pad name is mandatory'
         );
     }
@@ -694,7 +694,7 @@ Valve.prototype.setOpen = function() {
 
     if (!args.has.open) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: open is mandatory'
         );
     }
@@ -904,7 +904,7 @@ MachineLearningPipeline.prototype.unregisterCustomFilter = function() {
 
     if (!args.has.name) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: custom filter name is mandatory'
         );
     }
index 45278c9..38192a2 100755 (executable)
@@ -334,7 +334,7 @@ SingleShot.prototype.getValue = function() {
 
     if (!args.has.name) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: name is undefined'
         );
     }
@@ -371,7 +371,7 @@ SingleShot.prototype.setValue = function() {
 
     if (!args.has.name || !args.has.value) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: ' + (args.has.name ? 'value' : 'name') + ' is undefined'
         );
     }
@@ -393,10 +393,7 @@ SingleShot.prototype.setValue = function() {
     }
 };
 
-var SetTimeoutValidExceptions = [
-    'NotSupportedError',
-    'AbortError'
-];
+var SetTimeoutValidExceptions = ['NotSupportedError', 'AbortError'];
 SingleShot.prototype.setTimeout = function() {
     checkSingleShotNotClosed(this);
     var args = validator_.validateArgs(arguments, [
@@ -408,7 +405,7 @@ SingleShot.prototype.setTimeout = function() {
 
     if (!args.has.timeout) {
         throw new WebAPIException(
-            WebAPIException.INVALID_VALUES_ERR,
+            WebAPIException.TYPE_MISMATCH_ERR,
             'Invalid parameter: timeout is undefined'
         );
     }
@@ -428,9 +425,7 @@ SingleShot.prototype.setTimeout = function() {
     }
 };
 
-var CloseValidExceptions = [
-    'AbortError'
-];
+var CloseValidExceptions = ['AbortError'];
 SingleShot.prototype.close = function() {
     checkSingleShotNotClosed(this);
     var callArgs = {
@@ -439,11 +434,7 @@ SingleShot.prototype.close = function() {
 
     var result = native_.callSync('MLSingleShotClose', callArgs);
     if (native_.isFailure(result)) {
-        throw native_.getErrorObjectAndValidate(
-            result,
-            CloseValidExceptions,
-            AbortError
-        );
+        throw native_.getErrorObjectAndValidate(result, CloseValidExceptions, AbortError);
     }
     this._id = undefined;
 };
index 40f1dd7..3cb430a 100644 (file)
@@ -21,8 +21,9 @@ int main(int argc, char* argv[]) {
   ::testing::InitGoogleTest(&argc, argv);
   if (argc > 1) {
     if (strcmp("gbs", argv[1]) == 0) {
-      printf("WARNING: ML unit tests are not suitable to run inside GBS. "
-             "Please run these tests on real device.\n");
+      printf(
+          "WARNING: ML unit tests are not suitable to run inside GBS. "
+          "Please run these tests on real device.\n");
       return 0;
     }
   }