bijington/expressive

Null reference exception message surfacing from `Evaluate`

Opened this issue · 1 comments

Describe the bug

Certain expressions, seemingly those that have a negative sign followed by nothing (or perhaps other operators), throw an ExpressiveException the content of which is 'Object reference not set to an instance of an object.'. While obviously such an expression is not valid, and should throw some sort of exception, I'd expect it to be something a bit more user friendly. E.g. "The right hand side of the operation is missing".

To Reproduce

The extremely minimal repro of this is the following code.

using Expressive;
var expression = new  Expression("-");
expression.Evaluate();

More generally, seems to be for any operator that doesn't require a left hand side, when the right hand side is missing. E.g. ! or + as well as -.

Expected behavior

A more user friendly message explaining why the formula is invalid.

Screenshots

image

Platform (please complete the following information):
Seen on Windows, .NET 8 app, ExpressiveParser version 2.5.0

Additional context
Add any other context about the problem here.

Oh yeah that is a great find thanks! I would have expected a very similar error message to what you stated in your report.