-
Notifications
You must be signed in to change notification settings - Fork 66
Issues #41 Add errors when assert operators. #59
base: master
Are you sure you want to change the base?
Conversation
@@ -159,6 +166,10 @@ protected function visitOperator ( Ruler\Model\Operator $element, &$handle = nul | |||
$value = $argument->accept($this, $handle, $eldnah); | |||
$arguments[] = $value; | |||
|
|||
// Add operators name and their values in errors lists | |||
if (false === $value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why false
means a failed computation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the first assumption, generally when something is false
, this come from an error. But you're right sometimes we want to have false
as a correct value. This is also the reason why the operator not
exist. I see this in two way first is to found if this operator is used (not
operator) and invert the condition. But sometimes the value which should be used to raise an error could be other than "false". So the second way should be to add the false
value in operator to identify from which value you can add an error for this operator.
What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about letting the operator to register an error somewhere instead?
$asserter->setOperator(
'in',
function ( ) use ($asserter) {
// …
$asserter->addError(…);
return …;
}
);
How do you reset the list of errors from one execution to another? |
It's not possible for now to reset this list of errors from one execution to another. I will add it. Thanks for your feedback |
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.
Add resetErrors method! |
Don't rebase your patches each time. Just at the end. Good to have a |
@vonglasow ping? |
Yep sorry stand by during too long I will try to finish it ASAP |
No hurry 😃! |
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:
raised.
values.
Add error message when assert is false #41