Add create object function
This function takes in a object name, and a map of
variants, converts it to json, and creates a dbus-interface
after validating the json matches the correct schema.
Tested-by: Uploaded new Pid interface through D-Bus.
Change-Id: Ieec47a3f9fb53d5ac4f975f13ae6b8efd323971d
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/Utils.hpp b/include/Utils.hpp
index cd44082..39e3794 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -17,6 +17,7 @@
#pragma once
#include <experimental/filesystem>
#include <nlohmann/json.hpp>
+#include <sdbusplus/exception.hpp>
bool findFiles(const std::experimental::filesystem::path &dirPath,
const std::string &matchString,
@@ -24,3 +25,19 @@
bool validateJson(const nlohmann::json &schemaFile,
const nlohmann::json &input);
+struct DBusInternalError final : public sdbusplus::exception_t
+{
+ const char *name() const noexcept override
+ {
+ return "org.freedesktop.DBus.Error.Failed";
+ };
+ const char *description() const noexcept override
+ {
+ return "internal error";
+ };
+ const char *what() const noexcept override
+ {
+ return "org.freedesktop.DBus.Error.Failed: "
+ "internal error";
+ };
+};