Make a nicer diagnostic on parse error in pants.ini

Review Request #2907 - Created Sept. 30, 2015 and submitted

Information
Eric Ayers
pants
zundel/nicer-error-on-config-eval-error
2286
9d52db5...
Reviewers
pants-reviews
benjyw, gmalmquist, jsirois

Cleanup to give a nicer error output on misconfiguration in pants.ini that raises a SyntaxError from eval()

Was:

Exception caught:
  ...
  File "/Users/zundel/.pex/install/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl.d5493d74c62f5a977c5119c97760061ccd69069a/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl/pants/option/parser.py", line 401, in parse_typed_item
    return None if val_str is None else value_type(expand(val_str))
  File "/Users/zundel/.pex/install/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl.d5493d74c62f5a977c5119c97760061ccd69069a/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl/pants/option/custom_types.py", line 28, in list_option
    return _convert(s, (list, tuple))
  File "/Users/zundel/.pex/install/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl.d5493d74c62f5a977c5119c97760061ccd69069a/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl/pants/option/custom_types.py", line 52, in _convert
    return parse_expression(val, acceptable_types, raise_type=ParseError)
  File "/Users/zundel/.pex/install/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl.d5493d74c62f5a977c5119c97760061ccd69069a/pantsbuild.pants-0.0.49_square_20150924_01-py2-none-any.whl/pants/util/eval.py", line 46, in parse_expression
    parsed_value = eval(val)

Exception message: EOL while scanning string literal (<string>, line 5)

Now:

~/Development/java zundel/pants-sake-wire-codegen PANTS_DEV=1 ./pants compile service/exemplar 
2015-09-30 09:24:44,251: Regenerated BUILD files in 7.566 seconds.
Error in sys.excepthook:
Traceback (most recent call last):
  File "/Users/zundel/Src/pants/src/python/pants/bin/pants_exe.py", line 45, in unhandled_exception_hook
    msg = '\nException caught: ({})\n' + ''.join(type(exception), self._format_tb(tb))
TypeError: join() takes exactly one argument (2 given)

Original exception was:
Traceback (most recent call last):
  File "/Users/zundel/Src/pants/src/python/pants/bin/pants_exe.py", line 122, in <module>
    main()
  ...
  File "/Users/zundel/Src/pants/src/python/pants/option/custom_types.py", line 52, in _convert
    return parse_expression(val, acceptable_types, raise_type=ParseError)
  File "/Users/zundel/Src/pants/src/python/pants/util/eval.py", line 54, in parse_expression
    value=format_raw_value())))
pants.option.errors.ParseError:       The value cannot be evaluated as a literal expression: EOL while scanning string literal (<string>, line 5)
      Given raw value:
       1: [
 2: "squarepants.plugins.copy_signed_jars",
 3: "squarepants.plugins.repo",
 4: "squarepants.plugins.ruby",
 5: "squarepants.plugins.sake_wire_codegen',
 6: "squarepants.plugins.sjar",
 7: ]

(Having trouble with Pants and think you've found a bug?  Let us know with ./pants bug-report)
Eric Ayers
Benjy Weinberger
Eric Ayers
Review request changed

Status: Closed (submitted)

Change Summary:

Thanks Benjy, commit 3f1930f

Loading...