MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / check_errors

Function check_errors

tools/empath-split.py:120–152  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

118
119
120def check_errors(args):
121 if args.wasm and not os.path.isfile(args.wasm):
122 exit_with_error(f"'{args.wasm}' was not found or not a file")
123 if args.paths_file and not os.path.isfile(args.paths_file):
124 exit_with_error(f"'{args.paths_file}' was not found or not a file")
125
126 if args.sourcemap:
127 sourcemap = args.sourcemap
128
129 if args.wasm:
130 with webassembly.Module(args.wasm) as module:
131 if not args.sourcemap:
132 if not emsymbolizer.get_sourceMappingURL_section(module):
133 exit_with_error('sourceMappingURL section does not exist')
134 sourcemap = module.get_sourceMappingURL()
135 if not module.has_name_section():
136 exit_with_error('Name section does not exist')
137
138 if not os.path.isfile(sourcemap):
139 exit_with_error(f"'{sourcemap}' was not found or not a file")
140 if not os.path.isfile(args.wasm_split):
141 exit_with_error(f"'{args.wasm_split}' was not found or not a file")
142
143 # Check source map validity. Just perform simple checks to make sure mandatory
144 # fields exist.
145 json_data = utils.read_file(sourcemap)
146 try:
147 source_map_data = json.loads(json_data)
148 except json.JSONDecodeError:
149 exit_with_error(f'Invalid JSON format in file {args.sourcemap}')
150 for field in ['version', 'sources', 'mappings']:
151 if field not in source_map_data:
152 exit_with_error(f"Field '{field}' is missing in the source map")
153
154
155def get_sourceMappingURL(wasm, arg_sourcemap):

Callers 1

mainFunction · 0.85

Calls 3

exit_with_errorFunction · 0.90
get_sourceMappingURLMethod · 0.80
has_name_sectionMethod · 0.80

Tested by

no test coverage detected