diff --git a/python/gramine-manifest b/python/gramine-manifest index 749307fe7e..6a9d86cfa0 100755 --- a/python/gramine-manifest +++ b/python/gramine-manifest @@ -6,6 +6,11 @@ import click import voluptuous +try: + from tomllib import TOMLDecodeError +except ImportError: + from tomli import TOMLDecodeError + from graminelibos import Manifest def validate_define(_ctx, _param, values): @@ -28,9 +33,13 @@ def validate_define(_ctx, _param, values): @click.pass_context def main(ctx, string, define, infile, outfile, check): if not bool(string) ^ bool(infile): - click.get_current_context().fail('specify exactly one of (infile, -c)') + ctx.fail('specify exactly one of (infile, -c)') template = infile.read() if infile else string - manifest = Manifest.from_template(template, define) + try: + manifest = Manifest.from_template(template, define) + except TOMLDecodeError as err: + click.echo(f'ERROR: failed to parse manifest template: {err!s}', err=True) + ctx.exit(1) if check: try: