fix: Catching results exceptions properly

pull/340/head
chrisr3d 2019-10-08 15:48:26 +02:00
parent 2850d6f690
commit 8bcb630340
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 4 additions and 2 deletions

View File

@ -49,8 +49,10 @@ def handler(q=False):
try:
query_result = resolver.query(query, 'A')[0]
result = "{} - {}".format(requested_value, dbl_mapping[str(query_result)])
except Exception as e:
result = str(e)
except dns.resolver.NXDOMAIN as e:
result = e.msg
except Exception:
return {'error': 'Not able to reach dbl.spamhaus.org or something went wrong'}
return {'results': [{'types': mispattributes.get('output'), 'values': result}]}