NSLS2 / NSLS2/nsls2api

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

Open
#71 0 comments 0 reactions 1 assignee View on GitHub

@stuartcampbell is already working on this.

Since May 11, 2024.

Dominant language
Python
Stars
0
Forks
13
Avg merge
1h 17m
Merged PRs (30d)
1

Description

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

https://github.com/NSLS2/nsls2api/blob/a2de1f81dbc5b9cef843826e3c7b917ba77d6f58/src/nsls2api/services/pass_service.py#L75-L88

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 

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.