camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
120 stars 49 forks source link

Make failure messages more readable #713

Closed saig0 closed 10 months ago

saig0 commented 10 months ago

Description

Since version 1.17.0, we report failure messages if the evaluation results in null unintentionally. These failure messages are available for the caller of the API as part of the evaluation result.

Currently, these failure messages contain some technical details, like type information of the value. We should improve the readability of these messages.

For example

// Before
Can't compare ValNumber(1) with ValBoolean(true)

// After
Can't compare '1' with 'true'

it should "return null if the values have a different type" in {
    evaluateExpression("1 = true") should (returnNull() and reportFailure(
      failureType = EvaluationFailureType.NOT_COMPARABLE,
      failureMessage = "Can't compare ValNumber(1) with ValBoolean(true)"

💭 Val objects are only for internal usage. Maybe we can find a way to build the error message with the correct type, like boolean, string, number .....

_Originally posted by @nicpuppa in https://github.com/camunda/feel-scala/pull/711#discussion_r1325885261_