From 620e9f40c57b11cf76a60aaa4e4e8b44d54f0293 Mon Sep 17 00:00:00 2001 From: Jihoon Lee Date: Thu, 25 Feb 2021 13:46:30 +0900 Subject: [PATCH] [Fix/Svace] Add try catch to the top level app Add try catch to the top level app to ensure exception does not propagates to the very top level **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Jihoon Lee --- Applications/Custom/LayerClient/jni/main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Applications/Custom/LayerClient/jni/main.cpp b/Applications/Custom/LayerClient/jni/main.cpp index 6dc6d86..e685178 100644 --- a/Applications/Custom/LayerClient/jni/main.cpp +++ b/Applications/Custom/LayerClient/jni/main.cpp @@ -193,12 +193,18 @@ int main(int argc, char *argv[]) { return 1; } - auto &app_context = nntrainer::AppContext::Global(); - /// registering custom layer here - /// registerFactory excepts a function that returns unique_ptr from - /// std::vector ml::train::createLayer is a templated function - /// for generic usage - app_context.registerFactory(ml::train::createLayer); + try { + auto &app_context = nntrainer::AppContext::Global(); + /// registering custom layer here + /// registerFactory excepts a function that returns unique_ptr from + /// std::vector ml::train::createLayer is a templated + /// function for generic usage + app_context.registerFactory(ml::train::createLayer); + } catch (std::invalid_argument &e) { + std::cerr << "failed to register factory, reason: " << e.what() + << std::endl; + return 1; + } const std::string arg(argv[1]); -- 2.7.4