sensors: throw build time exceptions on failure

Throw build time exceptions on failure.

Change-Id: I7f873e15d0827b2424b9a1cfb6b494546952f1aa
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index 06d1289..ea4d7cb 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -69,7 +69,12 @@
             case IOInterfaceType::DBUSPASSIVE:
                 ri = DbusPassive::createDbusPassive(PassiveListeningBus,
                                                     info->type, name, &helper);
-                /* TODO(venture): if this returns nullptr */
+                if (ri == nullptr)
+                {
+                    throw SensorBuildException(
+                        "Failed to create dbus passive sensor: " + name +
+                        " of type: " + info->type);
+                }
                 break;
             case IOInterfaceType::EXTERNAL:
                 // These are a special case for read-only.
@@ -104,13 +109,18 @@
                     {
                         wi = DbusWritePercent::createDbusWrite(
                             info->writepath, info->min, info->max, helper);
-                        /* TODO: handle this being nullptr. */
                     }
                     else
                     {
                         wi = DbusWrite::createDbusWrite(
                             info->writepath, info->min, info->max, helper);
-                        /* TODO: handle this being nullptr. */
+                    }
+
+                    if (wi == nullptr)
+                    {
+                        throw SensorBuildException(
+                            "Unable to create write dbus interface for path: " +
+                            info->writepath);
                     }
 
                     break;