File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 2222
2323import hashlib
2424import json
25+ import logging
2526from contextlib import suppress
2627from pathlib import Path
2728
6263 },
6364}
6465
66+ logger = logging .getLogger (__name__ )
67+
6568
6669def is_source_mapping_in_minified (resource , map_file_name ):
6770 """Return True if a string contains a source mapping in its last 5 lines."""
@@ -89,11 +92,18 @@ def source_content_sha1_list(map_file):
8992
9093def load_json_from_file (location ):
9194 """Return the deserialized json content from ``location``."""
92- with open ( location ) as f :
93- try :
95+ try :
96+ with open ( location ) as f :
9497 return json .load (f )
95- except json .JSONDecodeError :
96- return
98+ except UnicodeDecodeError as e :
99+ logger .error (f"Failed to decode { location } as JSON: { str (e )} " )
100+ return
101+ except json .JSONDecodeError as e :
102+ logger .error (f"Invalid JSON format in { location } : { str (e )} " )
103+ return
104+ except Exception as e :
105+ logger .error (f"Unexpected error while reading { location } : { str (e )} " )
106+ return
97107
98108
99109def get_map_sources (map_file ):
You can’t perform that action at this time.
0 commit comments