Skip to content

Null reference exception message surfacing from Evaluate #137

@Mark-A-Williams

Description

@Mark-A-Williams

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions