Relocate and rename BaseException (#225)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 16 May 2018 23:43:41 +0000 (08:43 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 16 May 2018 23:43:41 +0000 (08:43 +0900)
* Relocate and rename BaseException

This commit relocates code related BaseException for consistency,
and renames it as 'Exception'.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
* Rewrite ConfigException in nnc

contrib/nnc/include/exception/ConfigException.h
contrib/nnc/src/exception/ConfigException.cpp
libs/foundation/include/nncc/foundation/Exception.h [moved from libs/foundation/include/exception/BaseException.h with 54% similarity]
libs/foundation/src/Exception.cpp [moved from libs/foundation/src/exception/BaseException.cpp with 54% similarity]
libs/foundation/src/Exception.test.cpp [moved from libs/foundation/src/exception.test.cpp with 68% similarity]

index ca1be44..1e986e0 100644 (file)
@@ -6,21 +6,21 @@
 
 #include <string>
 
-#include "exception/BaseException.h"
+#include <nncc/foundation/Exception.h>
 
 namespace nncc
 {
 namespace contrib
 {
 
-class ConfigException : public nncc::foundation::BaseException
+class ConfigException : public nncc::foundation::Exception
 {
 public:
   ConfigException() = default;
   ~ConfigException() throw() override = default;
 
   explicit ConfigException(const std::string &info);
-  explicit ConfigException(BaseException &e, const std::string &info);
+  explicit ConfigException(Exception &e, const std::string &info);
 };
 
 } // namespace contrib
index feb1154..1e21720 100644 (file)
@@ -11,9 +11,9 @@ namespace nncc
 namespace contrib
 {
 
-ConfigException::ConfigException(const std::string &info) : BaseException(info) {}
+ConfigException::ConfigException(const std::string &info) : Exception(info) {}
 
-ConfigException::ConfigException(BaseException &e, const std::string &info) : BaseException(e, info)
+ConfigException::ConfigException(Exception &e, const std::string &info) : Exception(e, info)
 {
 }
 
@@ -14,16 +14,16 @@ namespace nncc
 namespace foundation
 {
 
-class BaseException : public std::exception
+class Exception : public std::exception
 {
 public:
-  BaseException() = default;
-  ~BaseException() throw() override = default;
+  Exception() = default;
+  ~Exception() throw() override = default;
 
-  explicit BaseException(const std::string &info);
-  explicit BaseException(BaseException &e, const std::string &info);
+  explicit Exception(const std::string &info);
+  explicit Exception(Exception &e, const std::string &info);
 
-  BaseException &append(const std::string &info);
+  Exception &append(const std::string &info);
   const std::vector<std::string> &getInfo() const;
   const char *what() const throw() override;
 
@@ -31,7 +31,7 @@ private:
   std::vector<std::string> _info;
 };
 
-std::ostream &operator<<(std::ostream &s, const BaseException &e);
+std::ostream &operator<<(std::ostream &s, const Exception &e);
 
 } // namespace foundation
 } // namespace nncc
similarity index 54%
rename from libs/foundation/src/exception/BaseException.cpp
rename to libs/foundation/src/Exception.cpp
index eb9cde7..c677bba 100644 (file)
@@ -6,16 +6,16 @@
 #include <iostream>
 #include <stdexcept>
 
-#include "exception/BaseException.h"
+#include "nncc/foundation/Exception.h"
 
 namespace nncc
 {
 namespace foundation
 {
 
-BaseException::BaseException(const std::string &info) { _info.push_back(info); }
+Exception::Exception(const std::string &info) { _info.push_back(info); }
 
-BaseException::BaseException(BaseException &e, const std::string &info)
+Exception::Exception(Exception &e, const std::string &info)
 {
   for (auto errors : e.getInfo())
   {
@@ -24,21 +24,21 @@ BaseException::BaseException(BaseException &e, const std::string &info)
   _info.push_back(info);
 }
 
-const char *BaseException::what() const throw()
+const char *Exception::what() const throw()
 {
   // TODO implement it
   throw std::runtime_error{"Not implemented, yet"};
 }
 
-const std::vector<std::string> &BaseException::getInfo() const { return _info; }
+const std::vector<std::string> &Exception::getInfo() const { return _info; }
 
-BaseException &BaseException::append(const std::string &info)
+Exception &Exception::append(const std::string &info)
 {
   _info.push_back(info);
   return *this;
 }
 
-std::ostream &operator<<(std::ostream &s, const BaseException &e)
+std::ostream &operator<<(std::ostream &s, const Exception &e)
 {
   for (auto &errors : e.getInfo())
   {
similarity index 68%
rename from libs/foundation/src/exception.test.cpp
rename to libs/foundation/src/Exception.test.cpp
index 0e78c8d..e96ab46 100644 (file)
@@ -1,4 +1,4 @@
-#include <exception/BaseException.h>
+#include <nncc/foundation/Exception.h>
 
 #include <gtest/gtest.h>
 
@@ -10,7 +10,7 @@ std::string errorMsg3 = "error second constructor";
 
 std::vector<std::string> msgs = {errorMsg1, errorMsg2, errorMsg3};
 
-void err1() { throw BaseException(errorMsg1); }
+void err1() { throw Exception(errorMsg1); }
 
 void err2()
 {
@@ -18,7 +18,7 @@ void err2()
   {
     err1();
   }
-  catch (BaseException &e)
+  catch (Exception &e)
   {
     throw e.append(errorMsg2);
   }
@@ -30,19 +30,19 @@ void err3()
   {
     err2();
   }
-  catch (BaseException &e)
+  catch (Exception &e)
   {
-    throw BaseException(e, errorMsg3);
+    throw Exception(e, errorMsg3);
   }
 }
 
-TEST(FOUNDATION_EXCEPTION, BaseException)
+TEST(FOUNDATION_EXCEPTION, Exception)
 {
   try
   {
     err3();
   }
-  catch (BaseException &e)
+  catch (Exception &e)
   {
     ASSERT_TRUE(msgs == e.getInfo());
     return;