Added a try/catch to handle exceptions

Replaced the raise to send message to redis_logger
pull/586/head
TonyJabbour 2021-10-04 12:55:40 +02:00
parent 1c3ad52f5c
commit a2b28db32e
3 changed files with 20 additions and 9 deletions

View File

@ -109,9 +109,12 @@ class Tracker_Regex(AbstractModule):
"emailNotification": f'{mail_to_notify}', "emailNotification": f'{mail_to_notify}',
"trackerType": tracker_type "trackerType": tracker_type
} }
response = requests.post(webhook_to_post, json=json_request) try:
if response.status_code >= 400: response = requests.post(webhook_to_post, json=json_request)
raise Exception(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}") if response.status_code >= 400:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}")
except:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: Something went wrong")
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -152,9 +152,13 @@ class Tracker_Term(AbstractModule):
"emailNotification": f'{mail_to_notify}', "emailNotification": f'{mail_to_notify}',
"trackerType": term_type "trackerType": term_type
} }
response = requests.post(webhook_to_post, json=json_request) try:
if response.status_code >= 400: response = requests.post(webhook_to_post, json=json_request)
raise Exception(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}") if response.status_code >= 400:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}")
except:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: Something went wrong")
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -109,9 +109,13 @@ class Tracker_Yara(AbstractModule):
"emailNotification": f'{mail_to_notify}', "emailNotification": f'{mail_to_notify}',
"trackerType": "yara" "trackerType": "yara"
} }
response = requests.post(webhook_to_post, json=json_request) try:
if response.status_code >= 400: response = requests.post(webhook_to_post, json=json_request)
raise Exception(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}") if response.status_code >= 400:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}")
except:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: Something went wrong")
return yara.CALLBACK_CONTINUE return yara.CALLBACK_CONTINUE