Add better error messages

This commit is contained in:
zandercymatics 2023-11-13 08:16:51 -07:00
parent 6f528e8330
commit 1890cc8f26
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 27 additions and 4 deletions

View file

@ -1,4 +1,5 @@
import json import json
import os
import sys import sys
import csv import csv
import logging import logging
@ -426,6 +427,22 @@ class Command(BaseCommand):
# print message to terminal about which args are in use # print message to terminal about which args are in use
self.print_debug_mode_statements(debug_on, debug_max_entries_to_parse) self.print_debug_mode_statements(debug_on, debug_max_entries_to_parse)
filenames = [
agency_adhoc_filename,
domain_adhoc_filename,
organization_adhoc_filename,
domain_escrow_filename,
domain_additional_filename,
]
# Do a top-level check to see if these files exist
for filename in filenames:
if not isinstance(filename, str):
raise TypeError(f"Filename must be a string, got {type(filename).__name__}")
full_path = os.path.join(directory, filename)
if not os.path.isfile(full_path):
raise FileNotFoundError(full_path)
# STEP 1: # STEP 1:
# Create mapping of domain name -> status # Create mapping of domain name -> status
domain_status_dictionary = self.get_domain_user_dict( domain_status_dictionary = self.get_domain_user_dict(

View file

@ -867,8 +867,11 @@ class ExtraTransitionDomain:
) )
else: else:
if not infer_filenames: if not infer_filenames:
logger.error(f"Could not find file: {filename}") raise FileNotFoundError(
continue f"{TerminalColors.FAIL}"
f"Could not find file {filename} for {name}"
f"{TerminalColors.ENDC}"
)
# Infer filename logic # # Infer filename logic #
# This mode is used for # This mode is used for
@ -899,8 +902,11 @@ class ExtraTransitionDomain:
is_domain_escrow, is_domain_escrow,
) )
continue continue
# Log if we can't find the desired file raise FileNotFoundError(
logger.error(f"Could not find file: {filename}") f"{TerminalColors.FAIL}"
f"Could not find file {filename} for {name}"
f"{TerminalColors.ENDC}"
)
def clear_file_data(self): def clear_file_data(self):
for item in self.file_data.values(): for item in self.file_data.values():