changeset 1643:c04b5303eb08

try not to make empty topic subscriptions
author drewp@bigasterisk.com
date Fri, 17 Sep 2021 11:03:13 -0700
parents 78024b27f9ec
children 9e7f571deedf
files service/mqtt_to_rdf/mqtt_to_rdf.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/service/mqtt_to_rdf/mqtt_to_rdf.py	Fri Sep 17 11:01:06 2021 -0700
+++ b/service/mqtt_to_rdf/mqtt_to_rdf.py	Fri Sep 17 11:03:13 2021 -0700
@@ -224,6 +224,10 @@
     return n3
 
 
+class EmptyTopicError(ValueError):
+    pass
+
+
 class MqttStatementSource:
 
     def __init__(self, uri: URIRef, config: Graph, masterGraph: PatchableGraph, mqtt, internalMqtt, debugPageData,
@@ -238,6 +242,8 @@
         self.inference = inference
 
         self.mqttTopic = self.topicFromConfig(self.config)
+        if self.mqttTopic == b'':
+            raise EmptyTopicError(f"empty topic for {uri=}")
         log.debug(f'new mqttTopic {self.mqttTopic}')
 
         self.debugSub = {