Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions zabbix/zabbix_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,23 @@ def do_request(self, json_obj):
self.id += 1

if 'error' in jobj: # some exception
if not jobj['error'].has_key('code'):
msg = 'response does not contains error->code key"'
self.debug(logging.ERROR, msg)
raise ZabbixAPIException(msg)
if not jobj['error'].has_key('message'):
msg = 'response does not contains error->message key"'
self.debug(logging.ERROR, msg)
raise ZabbixAPIException(msg)
tmp_data = ""
if not jobj['error'].has_key('data'):
msg = 'response does not contains error->data key"'
self.debug(logging.INFO, msg)
else:
tmp_data = jobj['error']['data']
msg = "Error %s: %s, %s while sending %s" % (jobj['error']['code'],
jobj['error']['message'], jobj['error']['data'], str(json_obj))
if re.search(".*already\sexists.*", jobj["error"]["data"], re.I): # already exists
jobj['error']['message'], tmp_data, str(json_obj))
if re.search(".*already\sexists.*", tmp_data, re.I): # already exists
raise Already_Exists(msg, jobj['error']['code'])
else:
raise ZabbixAPIException(msg, jobj['error']['code'])
Expand Down