11from pathlib import Path
22from typing import List , Dict
33
4+ from requests import RequestException
5+ from requests .exceptions import HTTPError
6+
47from alephclient .api import AlephAPI , APIResultSet
58from alephclient .errors import AlephException
69
@@ -42,15 +45,15 @@ def _get_export(api: AlephAPI, export_id: str) -> Dict:
4245 for export in list_exports (api ):
4346 if str (export .get ("id" )) == str (export_id ):
4447 return export
45- raise AlephException (ValueError ( f"Export { export_id } not found" ) )
48+ raise AlephException (f"Export { export_id } not found" )
4649
4750
4851def download_export (api : AlephAPI , export_id : str , destination : str ) -> Path :
4952 """Download an export archive to the given destination path."""
5053 export = _get_export (api , export_id )
5154 download_url = export .get ("links" , {}).get ("download" )
5255 if not download_url :
53- raise AlephException (ValueError ( f"No download link for export { export_id } " ) )
56+ raise AlephException (f"No download link for export { export_id } " )
5457
5558 file_name = export .get ("file_name" , export_id )
5659 dest = Path (destination )
@@ -61,7 +64,7 @@ def download_export(api: AlephAPI, export_id: str, destination: str) -> Path:
6164 try :
6265 response = api .session .get (download_url , stream = True )
6366 response .raise_for_status ()
64- except Exception as exc :
67+ except ( RequestException , HTTPError ) as exc :
6568 raise AlephException (exc ) from exc
6669
6770 with open (dest , "wb" ) as fh :
0 commit comments