From: Wook Song Date: Wed, 10 Jun 2020 07:54:43 +0000 (+0900) Subject: [Filter/C++] Do not go further when failed to open NN framework X-Git-Tag: accepted/tizen/unified/20200629.143505~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a93758696298ea2f7439ccc0c262979fe736e440;p=platform%2Fupstream%2Fnnstreamer.git [Filter/C++] Do not go further when failed to open NN framework This patch adds more catch blocks that return negative error code in cpp_open so that the execution does not go further when it failed to open NN framework. Signed-off-by: Wook Song --- diff --git a/gst/nnstreamer/tensor_filter/tensor_filter_support_cc.cc b/gst/nnstreamer/tensor_filter/tensor_filter_support_cc.cc index 877f761..9933f4b 100644 --- a/gst/nnstreamer/tensor_filter/tensor_filter_support_cc.cc +++ b/gst/nnstreamer/tensor_filter/tensor_filter_support_cc.cc @@ -32,6 +32,9 @@ #include #include #include +#include + +#include #define __NO_ANONYMOUS_NESTED_STRUCT #include @@ -46,6 +49,11 @@ namespace nnstreamer { ******************************************************/ #define _SANITY_CHECK (0xFACE217714DEADE7ULL) +#define _RETURN_ERR_WITH_MSG(c, m) \ + do { \ + nns_loge ("%s", m); \ + return c; \ + } while (0); /** * @brief C tensor-filter wrapper callback function, "open" @@ -66,8 +74,17 @@ int tensor_filter_subplugin::cpp_open (const GstTensorFilterProperties * prop, tensor_filter_subplugin &obj = sp->getEmptyInstance(); try { obj.configure_instance (prop); + } catch (const std::invalid_argument & e) { + _RETURN_ERR_WITH_MSG (-EINVAL, e.what()); + } catch (const std::system_error & e) { + _RETURN_ERR_WITH_MSG (e.code().value() * -1, e.what()); + } catch (const std::runtime_error & e) { + /** @todo return different error codes according to exceptions */ + _RETURN_ERR_WITH_MSG (-1, e.what()); } catch (const std::exception & e) { - /* @todo Write exception handlers. */ + /** @todo Write exception handlers. */ + /** @todo return different error codes according to exceptions */ + _RETURN_ERR_WITH_MSG (-1, e.what()); } /* 3. Mark that this is not a representative (found by nnstreamer_filter_find) empty object */