[fix] never do catch all exceptions

This commit is contained in:
Laurent Peuch 2021-01-08 02:33:56 +01:00
parent f5e9385955
commit 69d6d54911

View file

@ -24,6 +24,7 @@ RATE_LIMIT_DB = {}
RATE_LIMIT_SECONDS = 300 RATE_LIMIT_SECONDS = 300
RATE_LIMIT_NB_REQUESTS = 10 RATE_LIMIT_NB_REQUESTS = 10
def clear_rate_limit_db(now): def clear_rate_limit_db(now):
to_delete = [] to_delete = []
@ -349,7 +350,10 @@ async def check_smtp(request):
recv = sock.recv(1024).decode('utf-8') recv = sock.recv(1024).decode('utf-8')
assert recv[:3] == "220" assert recv[:3] == "220"
helo_domain = recv.split()[1].strip() helo_domain = recv.split()[1].strip()
except: except Exception as e:
import traceback
traceback.print_exc()
print(f"Error when trying to get smtp answer: {e}")
return json_response({ return json_response({
'status': "error_smtp_bad_answer", 'status': "error_smtp_bad_answer",
'content': "SMTP server did not reply with '220 domain.tld' after opening socket ... Maybe another machine answered." 'content': "SMTP server did not reply with '220 domain.tld' after opening socket ... Maybe another machine answered."