Skip to content

Commit

Permalink
refactor: condense exception annotating (#501)
Browse files Browse the repository at this point in the history
`Logger.exception()` captures the exception name and a stack trace, so
there's no need to be writing out these conditions for different
exceptions that differ only by naming the exception
  • Loading branch information
jsstevenson authored Feb 7, 2025
1 parent f44d184 commit 13119ba
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions src/ga4gh/vrs/extras/annotator/vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

import pysam
from biocommons.seqrepo import SeqRepo
from pydantic import ValidationError

from ga4gh.core.identifiers import (
VrsObjectIdentifierIs,
use_ga4gh_compute_identifier_when,
)
from ga4gh.vrs.dataproxy import (
DataProxyValidationError,
SeqRepoDataProxy,
SeqRepoRESTDataProxy,
)
Expand Down Expand Up @@ -258,33 +256,16 @@ def _get_vrs_object(
assembly_name=assembly,
require_validation=require_validation,
)
except (ValidationError, DataProxyValidationError):
vrs_obj = None
_logger.exception(
"ValidationError when translating %s from gnomad", vcf_coords
)
raise
except KeyError:
vrs_obj = None
_logger.exception("KeyError when translating %s from gnomad", vcf_coords)
raise
except AssertionError:
vrs_obj = None
_logger.exception(
"AssertionError when translating %s from gnomad", vcf_coords
)
raise
except Exception:
vrs_obj = None
_logger.exception(
"Unhandled Exception when translating %s from gnomad", vcf_coords
"Exception encountered during translation of variation: %s", vcf_coords
)
raise
else:
if not vrs_obj:
_logger.debug(
"None was returned when translating %s from gnomad", vcf_coords
)
if vrs_obj is None:
_logger.debug(
"None was returned when translating %s from gnomad", vcf_coords
)

if vrs_data and vrs_obj:
key = vrs_data_key if vrs_data_key else vcf_coords
Expand Down

0 comments on commit 13119ba

Please sign in to comment.