dbus: dbuswrite: use factory to catch errors
Add factories for creating DbusWrite and DbusWritePercent objects and
use these factories.
Change-Id: Iad222d4bf6c1fdf561daa4ba9d88a6644c0a5965
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index 15d479c..0f2f0c7 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -101,13 +101,15 @@
case IOInterfaceType::DBUSACTIVE:
if (info->max > 0)
{
- wi = std::make_unique<DbusWritePercent>(
+ wi = DbusWritePercent::createDbusWrite(
info->writepath, info->min, info->max, helper);
+ /* TODO: handle this being nullptr. */
}
else
{
- wi = std::make_unique<DbusWrite>(
+ wi = DbusWrite::createDbusWrite(
info->writepath, info->min, info->max, helper);
+ /* TODO: handle this being nullptr. */
}
break;