Add sysrepo error handling
Change-Id: I810de1afd0ad6161a18903f816e19db28ed9edf1
diff --git a/src/datastore_access.cpp b/src/datastore_access.cpp
index 2b7243b..6e3b37a 100644
--- a/src/datastore_access.cpp
+++ b/src/datastore_access.cpp
@@ -8,4 +8,30 @@
#include "datastore_access.hpp"
+DatastoreError::DatastoreError(const std::string& message, const std::optional<std::string>& xpath)
+ : message(message)
+ , xpath(xpath)
+{
+}
+
DatastoreAccess::~DatastoreAccess() = default;
+
+DatastoreException::DatastoreException(const std::vector<DatastoreError>& errors)
+{
+ m_what = "The following errors occured:\n";
+ for (const auto& it : errors) {
+ m_what += " Message: ";
+ m_what += it.message;
+ m_what += "\n";
+ if (it.xpath) {
+ m_what += " Xpath: ";
+ m_what += it.xpath.value();
+ m_what += "\n";
+ }
+ }
+}
+
+const char* DatastoreException::what() const noexcept
+{
+ return m_what.c_str();
+}