Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolate pass service errors & potentially log and discard invalid proposal info #71

Open
padraic-shafer opened this issue May 2, 2024 · 0 comments
Assignees

Comments

@padraic-shafer
Copy link
Collaborator

Consider breaking up the try-catch blocks here (and similar uses elsewhere) to:

  1. Isolate the source of an error
  2. Possibly log and then discard invalid proposal types

try:
pass_proposal_types_list = await _call_pass_webservice(url)
proposal_types = []
if pass_proposal_types_list and len(pass_proposal_types_list) > 0:
for proposal_type in pass_proposal_types_list:
proposal_types.append(PassProposalType(**proposal_type))
except ValidationError as error:
error_message = f"Error validating data recevied from PASS for proposal type for the {facility} facility."
logger.error(error_message)
raise PassException(error_message) from error
except Exception as error:
error_message = "Error retrieving proposal types from PASS."
logger.exception(error_message)
raise PassException(error_message) from error

For example:

 try: 
     pass_proposal_types_list = await _call_pass_webservice(url) 
 except Exception as error: 
     error_message = "Error retrieving proposal types from PASS." 
     logger.exception(error_message) 
     raise PassException(error_message) from error 

proposal_types = [] 
if pass_proposal_types_list and len(pass_proposal_types_list) > 0: 
    for proposal_type in pass_proposal_types_list: 
        try: 
            proposal_types.append(PassProposalType(**proposal_type)) 
        except ValidationError as error: 
            error_message = f"Error validating data recevied from PASS for proposal type for the {facility} facility." 
            logger.error(error_message) 
            # raise PassException(error_message) from error 
@stuartcampbell stuartcampbell self-assigned this May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants