Change exception::invalid_prop -> not_supported
authorJihoon Lee <jhoon.it.lee@samsung.com>
Wed, 29 Jul 2020 11:06:41 +0000 (20:06 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Mon, 3 Aug 2020 02:08:48 +0000 (11:08 +0900)
Change invalid_prop -> not supported for generality

**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jihoon Lee <jhoon.it.lee@samsung.com>
api/capi/src/nntrainer.cpp
nntrainer/include/layer.h
nntrainer/include/nntrainer_error.h
nntrainer/src/flatten_layer.cpp
nntrainer/src/layer.cpp
nntrainer/src/loss_layer.cpp
nntrainer/src/neuralnet.cpp

index 3644be04e4bb70f8bace4be2ebddda7e00435418..15654b1c36456e7bc51e8b8ccad13c098f27a586 100644 (file)
@@ -61,7 +61,7 @@ template <typename F> static int nntrainer_exception_boundary(F &&func) {
   /// caught before than some
   try {
     status = func();
-  } catch (nntrainer::exception::invalid_property &e) {
+  } catch (nntrainer::exception::not_supported &e) {
     ml_loge("%s %s", typeid(e).name(), e.what());
     return ML_ERROR_INVALID_PARAMETER;
   } catch (std::invalid_argument &e) {
index 3f706e5c2e3a75be97ab25a038161ee0b02327c7..adfb2382af1e2953d8b020c70717779f9f4afa5c 100644 (file)
@@ -261,9 +261,9 @@ public:
    * @param[in] type property type to be passed
    * @param[in] value value to be passed, if empty string is passed, do nothing
    * but throws error when @a type is invalid
-   * @exception std::out_of_range     when property type is not valid for the
-   * particular layer
-   * @exception exception::invalid_property invalid argument
+   * @exception exception::not_supported     when property type is not valid for
+   * the particular layer
+   * @exception std::invalid_argument invalid argument
    */
   virtual void setProperty(const PropertyType type,
                            const std::string &value = "");
index c5a23523b56a61d40b17d17553335a4b958caab0..343ac179b2d9277fc6a53c1205bb6b8ce97b2f49 100644 (file)
@@ -44,9 +44,11 @@ namespace nntrainer {
 namespace exception {
 
 /**
- * @brief derived class of invalid argument to represent property is invalid
+ * @brief derived class of invalid argument to represent specific functionality
+ * not supported
+ * @note this could be either intended or not yet implemented
  */
-struct invalid_property : public std::invalid_argument {
+struct not_supported : public std::invalid_argument {
   using invalid_argument::invalid_argument;
 };
 
index 360ea35b1c41839d9c8079d9e5b0694134d69657..ade6c30f6465dabb5e9db87d37b4a4303f4df902 100644 (file)
@@ -59,8 +59,7 @@ Tensor FlattenLayer::backwarding(Tensor in, int iteration) {
 
 void FlattenLayer::setProperty(const PropertyType type,
                                const std::string &value) {
-  throw exception::invalid_property(
-    "[Flatten Layer] setProperty not supported");
+  throw exception::not_supported("[Flatten Layer] setProperty not supported");
 }
 
 void FlattenLayer::copy(std::shared_ptr<Layer> l) {
index 7b5efc70bc732aac959a9d44c92b25245f0cd56f..3b2dffa24dbe2c210616b003f05f1cd5eb34e517 100644 (file)
@@ -212,7 +212,7 @@ void Layer::setProperty(const PropertyType type, const std::string &value) {
   default:
     std::string msg =
       "[Layer] Unknown Layer Property Key for value" + std::string(value);
-    throw exception::invalid_property(msg);
+    throw exception::not_supported(msg);
   }
 }
 
@@ -229,7 +229,7 @@ void Layer::printIfValid(std::ostream &out, const PropertyType type,
                          const T target) {
   try {
     setProperty(type);
-  } catch (exception::invalid_property &e) {
+  } catch (exception::not_supported &e) {
     return;
   }
 
index f5c70a32aef79f2f3e920d06a364c463699cf353..db397160734b50e8c6726b2d8cd4469553875aef 100644 (file)
@@ -153,7 +153,7 @@ Tensor LossLayer::forwarding(Tensor in, int &status) {
 }
 
 void LossLayer::setProperty(const PropertyType type, const std::string &value) {
-  throw exception::invalid_property("[Loss Layer] setProperty not supported");
+  throw exception::not_supported("[Loss Layer] setProperty not supported");
 }
 
 } /* namespace nntrainer */
index ae575fd625c40f2e163ec598c25f3d976d51944c..d25508657dc0fb93f4a773b0aaf95743f32b7da6 100644 (file)
@@ -276,7 +276,7 @@ int NeuralNetwork::loadFromConfig() {
 
       /**! @todo: add following negative tc after #319
        * 1. layer has empty prop -> throw std::invalid_argument
-       * 2. layer has not allowed property -> throw exception::invalid_property
+       * 2. layer has not allowed property -> throw exception::not_supported
        * 3. property value parse error -> throw std::invalid_argument
        */
       if (!strncmp(value.c_str(), unknown, unknown_len)) {