Skip to content

Commit 8b1ba0c

Browse files
committed
improve error handing
Signed-off-by: hwassman <[email protected]>
1 parent 2345cf7 commit 8b1ba0c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

source/collector.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ def get_zimon_query(self):
214214
query.rawData = self.rawData
215215

216216
if not self.metricsaggr and not self.sensor:
217-
self.logger.error(MSG['QueryError'].
218-
format('Missing metric or sensor name'))
219-
raise cherrypy.HTTPError(400, ERR[400])
217+
raise ValueError('Missing metric or sensor name')
220218

221219
if self.metricsaggr:
222220
for key, value in self.metricsaggr.items():
@@ -341,7 +339,12 @@ def _calc_ds_interval(self) -> int:
341339
def _collect(self):
342340
'''Executes zimon query and returns results'''
343341

344-
res = self.md.qh.runQuery(self.query)
342+
try:
343+
res = self.md.qh.runQuery(self.query)
344+
except Exception as e:
345+
self.logger.error(MSG['QueryError'].format(e))
346+
return
347+
345348
if res is None:
346349
self.logger.error(MSG['NoData'])
347350
# self.stop_collect()

0 commit comments

Comments
 (0)