From 25be25e1569ce2c732e3fd5f0aaeaa5ba53f02e1 Mon Sep 17 00:00:00 2001 From: Rafal Walczyna Date: Thu, 11 Mar 2021 15:06:57 +0100 Subject: [PATCH] [ML] Change InvalidValuesError to TypeMismatchError for no args 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 --- src/ml/js/ml_common.js | 14 +++++++------- src/ml/js/ml_pipeline.js | 12 ++++++------ src/ml/js/ml_single.js | 21 ++++++--------------- src/ml/ut/main.cc | 5 +++-- 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/ml/js/ml_common.js b/src/ml/js/ml_common.js index cb863c8..e38f097 100755 --- a/src/ml/js/ml_common.js +++ b/src/ml/js/ml_common.js @@ -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' ); } diff --git a/src/ml/js/ml_pipeline.js b/src/ml/js/ml_pipeline.js index f9a285f..5f29c51 100755 --- a/src/ml/js/ml_pipeline.js +++ b/src/ml/js/ml_pipeline.js @@ -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' ); } diff --git a/src/ml/js/ml_single.js b/src/ml/js/ml_single.js index 45278c9..38192a2 100755 --- a/src/ml/js/ml_single.js +++ b/src/ml/js/ml_single.js @@ -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; }; diff --git a/src/ml/ut/main.cc b/src/ml/ut/main.cc index 40f1dd7..3cb430a 100644 --- a/src/ml/ut/main.cc +++ b/src/ml/ut/main.cc @@ -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; } } -- 2.7.4