@@ -134,7 +134,7 @@ def parse_nfts(self, fetch_result: FetchResult) -> ParseResult:
134134 errors .append ("No data in API response" )
135135 return ParseResult (data = [], errors = errors )
136136
137- address = None
137+ address : str | None = None
138138 if hasattr (fetch_result , "extra" ) and isinstance (fetch_result .extra , dict ):
139139 address = fetch_result .extra .get ("address" )
140140
@@ -145,16 +145,15 @@ def parse_nfts(self, fetch_result: FetchResult) -> ParseResult:
145145 address = first_item .get ("address" ) or first_item .get ("utxo" , {}).get (
146146 "address"
147147 )
148- except Exception :
148+ except ( IndexError , AttributeError , TypeError ) :
149149 address = None
150150
151151 collection_map : Dict [str , Tuple [str , str ]] = {}
152- if address :
153- try :
154- collection_map = self ._build_collection_map (address )
155- except ValueError as exc :
156- errors .append (str (exc ))
157- return ParseResult (errors = errors )
152+ try :
153+ collection_map = self ._build_collection_map (address )
154+ except ValueError as exc :
155+ errors .append (str (exc ))
156+ return ParseResult (errors = errors )
158157
159158 for nft in self ._yield_parsed_nfts (inner_data , collection_map ):
160159 data .append (nft )
@@ -224,11 +223,14 @@ def _build_collection_map(self, address: str) -> Dict[str, Tuple[str, str]]:
224223 ValueError
225224 If UniSat returns a non‑zero `code` (e.g. -119 = address invalid).
226225 """
227- resp = self .post (
228- "get_collection_summary" ,
229- json = {"address" : address },
230- headers = self .headers ,
231- )
226+ try :
227+ resp = self .post (
228+ "get_collection_summary" ,
229+ json = {"address" : address },
230+ headers = self .headers ,
231+ )
232+ except Exception as exc :
233+ raise ValueError (f"UniSat request failed: { exc } " ) from exc
232234
233235 if not isinstance (resp , dict ):
234236 raise ValueError ("Unexpected response object from UniSat" )
0 commit comments