55from cool_seq_tool .schemas import AnnotationLayer
66from fastapi import APIRouter , HTTPException
77from fastapi .responses import JSONResponse
8- from requests import HTTPError
8+ from httpx import HTTPStatusError
99
1010from dcd_mapping .align import build_alignment_result
1111from dcd_mapping .annotate import (
@@ -64,6 +64,7 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
6464 records = get_scoreset_records (metadata , True , store_path )
6565 metadata = patch_target_sequence_type (metadata , records , force = False )
6666 except ScoresetNotSupportedError as e :
67+ _logger .error ("Scoreset not supported for %s: %s" , urn , e )
6768 return JSONResponse (
6869 content = ScoresetMapping (
6970 metadata = None ,
@@ -72,6 +73,7 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
7273 )
7374 except ResourceAcquisitionError as e :
7475 msg = f"Unable to acquire resource from MaveDB: { e } "
76+ _logger .error (msg )
7577 raise HTTPException (status_code = 500 , detail = msg ) from e
7678
7779 if not records :
@@ -87,17 +89,21 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
8789 alignment_results = build_alignment_result (metadata , True )
8890 except BlatNotFoundError as e :
8991 msg = "BLAT command appears missing. Ensure it is available on the $PATH or use the environment variable BLAT_BIN_PATH to point to it. See instructions in the README prerequisites section for more."
92+ _logger .error ("BLAT not found for %s: %s" , urn , e )
9093 raise HTTPException (status_code = 500 , detail = msg ) from e
9194 except ResourceAcquisitionError as e :
9295 msg = f"BLAT resource could not be acquired: { e } "
96+ _logger .error (msg )
9397 raise HTTPException (status_code = 500 , detail = msg ) from e
9498 except AlignmentError as e :
99+ _logger .error ("Alignment error for %s: %s" , urn , e )
95100 return JSONResponse (
96101 content = ScoresetMapping (
97102 metadata = metadata , error_message = str (e ).strip ("'" )
98103 ).model_dump (exclude_none = True )
99104 )
100105 except ScoresetNotSupportedError as e :
106+ _logger .error ("Scoreset not supported during alignment for %s: %s" , urn , e )
101107 return JSONResponse (
102108 content = ScoresetMapping (
103109 metadata = metadata , error_message = str (e ).strip ("'" )
@@ -111,11 +117,13 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
111117 # on the target level and on the variant level for variants relative to that target
112118 # HTTPErrors and DataLookupErrors cause the mapping process to exit because these indicate
113119 # underlying issues with data providers.
114- except HTTPError as e :
120+ except HTTPStatusError as e :
115121 msg = f"HTTP error occurred during transcript selection: { e } "
122+ _logger .error (msg )
116123 raise HTTPException (status_code = 500 , detail = msg ) from e
117124 except DataLookupError as e :
118125 msg = f"Data lookup error occurred during transcript selection: { e } "
126+ _logger .error (msg )
119127 raise HTTPException (status_code = 500 , detail = msg ) from e
120128
121129 vrs_results = {}
@@ -134,6 +142,7 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
134142 UnsupportedReferenceSequencePrefixError ,
135143 MissingSequenceIdError ,
136144 ) as e :
145+ _logger .error ("VRS mapping error for %s: %s" , urn , e )
137146 return JSONResponse (
138147 content = ScoresetMapping (
139148 metadata = metadata , error_message = str (e ).strip ("'" )
@@ -172,6 +181,7 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
172181 VrsVersion .V_2 ,
173182 )
174183 except Exception as e :
184+ _logger .error ("Unexpected error during annotation for %s: %s" , urn , e )
175185 return JSONResponse (
176186 content = ScoresetMapping (
177187 metadata = metadata , error_message = str (e ).strip ("'" )
@@ -287,6 +297,7 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
287297 del reference_sequences [target_gene ].layers [layer ]
288298
289299 except Exception as e :
300+ _logger .error ("Unexpected error during result assembly for %s: %s" , urn , e )
290301 return JSONResponse (
291302 content = ScoresetMapping (
292303 metadata = metadata , error_message = str (e ).strip ("'" )
0 commit comments