Hi!

I've implemented a new error handling functionality for NAnt expression
evaluator. It allows you to spot the expression errors more quickly and
gives you detailed information about the error itself.

A visual string of ^^^^^^^^^^^^^^ characters is used to underline the source
of an error.
I've attached some examples of new error messages.

The code is in CVS. I'm awaiting your comments.

Some ideas/concerns:

1. I think that the code for ExpressionEvalBase.SafeConvert() and
ExpressionEvalBase.GetSimpleTypeName() could/should be reused in all places
where conversion is currently used. This isn't directly doable now, but
that's the idea.

2. I didn't know to produce line number and file name in the output, but
this should be easy to add because the whole magic of catching
ExpressionParseException and re-throwing BuildException happens in a single
place in PropertyDictionary.EvaluateEmbeddedExpressions() where "Location"
seems to be available. Can someone help me here?

3. I use exception messages with embedded newlines - this isn't the best
style but works. Does anyone have any better suggestions?

Jarek
-------------------------

Error: Unknown function 'aaa::bbb'.
Expression: ${aaa::bbb('aaa')}
              ^^^^^^^^^
-------------------------
Error: ',' expected.
Expression: ${nant::property-exists('aaa'}
                                         ^
-------------------------
Error: Cannot convert the right hand side of the subtraction operator to 'integer' 
(actual type was 'string').
Expression: ${1-'aaa'}
                ^^^^^
-------------------------
Error: Cannot convert the argument of 'not' operator to 'boolean' (actual type was 
'string').
Expression: ${1-not '1'}
                    ^^^
-------------------------
Error: Too few actual parameters for 'nant::get-property-value'.
Expression: ${nant::get-property-value()}
              ^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------
Error: Too many actual parameters for 'nant::get-property-value'.
Expression: ${nant::get-property-value('nant.project.basedir','extra_param')}
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------
Error: Cannot convert argument 1(value) of math::round() to 'double' (actual type was 
'string').
Expression: ${math::round('aaa')}
                          ^^^^^
-------------------------
Error: Cannot convert argument 1(value) of math::round() to 'double' (actual type was 
'boolean').
Expression: ${math::round(true)}
                          ^^^^
-------------------------

Reply via email to