-
Notifications
You must be signed in to change notification settings - Fork 66
Add error message when assert is false #41
Comments
Huge 👍 on this one! |
👍 |
1 similar comment
+1 |
When operators are evaluated, we can found some asserter false. This patch add a management of errors in the asserter. Operators name and value is added in errors stack to identify which operator fail. Two methods are available to identify if we have errors and to get there errors: * hasErrors return a boolean which identify if some errors have been raised. * getErrors return an array with operator name as key and arguments as values.
When operators are evaluated, we can found some asserter false. This patch add a management of errors in the asserter. Operators name and value is added in errors stack to identify which operator fail. Two methods are available to identify if we have errors and to get there errors: * hasErrors return a boolean which identify if some errors have been raised. * getErrors return an array with operator name as key and arguments as values. * resetErrors clean all errors stored.
It seems compex to explain what is wrong if the function has more parameter.
? Perhaps, something like SQL explain should be more generic, even the message wil be more technical. I see a response like:
|
And a complete explaination:
|
@vonglasow Perhaps using a Closure to define the context is not a good practice? |
@1e1 I like your proposal in #41 (comment), having the tree/AST view of the rule with associated error is a good |
@1e1 array(1) {
["f"]=>
array(1) {
[0]=>
object(Hoa\Ruler\Model\Bag\Scalar)#251 (1) {
["_value":protected]=>
bool(false)
}
}
} But we can improve it. I will try to make a test with your exemple to show you what is done yet. And if you have any idea to make this AST let me know we can work on it together. |
@vonglasow Not sure. I don't know what the user needs exactly here. It is not defined. In what case are we likely to use the errors API? What do we expect? What information do we need? |
Take an example
Ok so we have here a rule not respected, but why this rule doesn't passed is it because we have the user logout or because them points is <= 30
It could be useful to identify the reason of breaking rules. But all rules depends on operator so I think the operator could provide a property with error message when the result of validation is false and aggregate in ruler to got it.
To continue the example above
What do you think ?
The text was updated successfully, but these errors were encountered: