smtpdummy: Better error handling

This commit is contained in:
Geoffrey Frogeye 2021-10-17 14:33:33 +02:00
parent fd4722f989
commit 72e37e0921

View file

@ -141,7 +141,10 @@ Input arguments:
next = True next = True
while next: while next:
line = p.stdout.readline() line = p.stdout.readline()
try:
code = int(line[:3]) code = int(line[:3])
except ValueError:
raise ValueError(f"Could not parse line: '{line.decode()}'")
success = code < 400 success = code < 400
color = colorama.Fore.GREEN if success else colorama.Fore.RED color = colorama.Fore.GREEN if success else colorama.Fore.RED
if not args.quiet: if not args.quiet: