Skip to content

Commit a23b67a

Browse files
authored
[file_packager] Cleanup error handling. NFC (#24993)
1 parent 0919a02 commit a23b67a

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

tools/file_packager.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,10 @@ def main(): # noqa: C901, PLR0912, PLR0915
446446
explicit_dst_path=uses_at_notation))
447447
else:
448448
diagnostics.error(f'${arg} does not exist')
449-
return 1
450449
elif leading == 'exclude':
451450
excluded_patterns.append(arg)
452451
else:
453452
diagnostics.error('Unknown parameter:', arg)
454-
return 1
455453

456454
options.has_preloaded = any(f.mode == 'preload' for f in data_files)
457455
options.has_embedded = any(f.mode == 'embed' for f in data_files)
@@ -461,24 +459,18 @@ def main(): # noqa: C901, PLR0912, PLR0915
461459
'for deprecation. If you need this feature please comment at '
462460
'https://github.com/emscripten-core/emscripten/issues/24803')
463461

464-
if options.separate_metadata:
465-
if not options.has_preloaded or not options.jsoutput:
466-
err('cannot separate-metadata without both --preloaded files '
467-
'and a specified --js-output')
468-
return 1
462+
if options.separate_metadata and (not options.has_preloaded or not options.jsoutput):
463+
diagnostics.error('cannot separate-metadata without both --preloaded files and a specified --js-output')
469464

470465
if not options.from_emcc and not options.quiet:
471466
diagnostics.warn('Remember to build the main file with `-sFORCE_FILESYSTEM` '
472467
'so that it includes support for loading this file package')
473468

474469
if options.jsoutput and os.path.abspath(options.jsoutput) == os.path.abspath(data_target):
475470
diagnostics.error('TARGET should not be the same value of --js-output')
476-
return 1
477471

478472
if options.from_emcc and options.export_es6:
479-
diagnostics.error('Can\'t use --export-es6 option together with --from-emcc since the code should be embedded '
480-
'within emcc\'s code')
481-
return 1
473+
diagnostics.error("Can't use --export-es6 option together with --from-emcc since the code should be embedded within emcc's code")
482474

483475
walked.append(__file__)
484476
for file_ in data_files:
@@ -492,7 +484,6 @@ def main(): # noqa: C901, PLR0912, PLR0915
492484
if not os.path.isdir(file_.srcpath)]
493485
if len(data_files) == 0:
494486
diagnostics.error('Nothing to do!')
495-
sys.exit(1)
496487

497488
# Absolutize paths, and check that they make sense
498489
# os.getcwd() always returns the hard path with any symbolic links resolved,
@@ -557,7 +548,6 @@ def was_seen(name):
557548
if options.obj_output:
558549
if not options.has_embedded:
559550
diagnostics.error('--obj-output is only applicable when embedding files')
560-
return 1
561551
generate_object_file(data_files)
562552
if not options.has_preloaded:
563553
return 0

0 commit comments

Comments
 (0)