[Fix/Svace] Add try catch to model-run
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 3 Mar 2021 02:11:51 +0000 (11:11 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Wed, 3 Mar 2021 06:43:13 +0000 (15:43 +0900)
The two functions of the following code may throw
exceptions. Handle them.
```
if (arg == "model") {
  return api_model_run();
} else {
  return ini_model_run(arg);
}
```

This fixes SVACE 457479.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Applications/Custom/LayerClient/jni/main.cpp

index e685178..5e1cc98 100644 (file)
@@ -208,10 +208,15 @@ int main(int argc, char *argv[]) {
 
   const std::string arg(argv[1]);
 
-  if (arg == "model") {
-    return api_model_run();
-  } else {
-    return ini_model_run(arg);
+  try {
+    if (arg == "model") {
+      return api_model_run();
+    } else {
+      return ini_model_run(arg);
+    }
+  } catch (std::invalid_argument &e) {
+    std::cerr << "failed to run the model, reason: " << e.what() << std::endl;
+    return 1;
   }
 
   /// should not reach here