[foundation] Implemented 'Exception' class 'what()' method (#351)
authorIvan Vagin/AI Tools Lab /SRR/Engineer/삼성전자 <ivan.vagin@samsung.com>
Wed, 27 Jun 2018 07:18:04 +0000 (10:18 +0300)
committerSergey Vostokov/AI Tools Lab /SRR/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Wed, 27 Jun 2018 07:18:04 +0000 (16:18 +0900)
Implemented 'Exception' class 'what()' method

This commit introduced 'what()' method 'Exception' class

Signed-off-by: Ivan Vagin <ivan.vagin@samsung.com>
libs/foundation/include/nncc/foundation/Exception.h
libs/foundation/src/Exception.cpp

index 1238b1d..ae68e34 100644 (file)
@@ -29,6 +29,7 @@ public:
 
 private:
   std::vector<std::string> _info;
+  mutable std::string _sInfo;
 };
 
 std::ostream &operator<<(std::ostream &s, const Exception &e);
index c677bba..8cdfcb6 100644 (file)
@@ -26,8 +26,10 @@ Exception::Exception(Exception &e, const std::string &info)
 
 const char *Exception::what() const throw()
 {
-  // TODO implement it
-  throw std::runtime_error{"Not implemented, yet"};
+  _sInfo.clear();
+  for (auto it : _info)
+    _sInfo.append(it).append("\n");
+  return _sInfo.c_str();
 }
 
 const std::vector<std::string> &Exception::getInfo() const { return _info; }