Browse files

slightly more descriptive error

  • Loading branch information...
1 parent bf22144 commit 4636edb365ec23da6c9082502575c79ce4bada8b @davedelong committed Nov 25, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 DDMathParser/_DDOperatorTerm.m
View
10 DDMathParser/_DDOperatorTerm.m
@@ -33,7 +33,15 @@ - (NSString *)operatorFunction {
- (BOOL)resolveWithParser:(DDParser *)parser error:(NSError *__autoreleasing *)error {
#pragma unused(parser)
ERR_ASSERT(error);
- *error = ERR(DDErrorCodeOperatorMissingOperands, @"missing operand(s) for operator: %@", [self token]);
+ if ([self operatorArity] == DDOperatorArityUnary) {
+ if ([[self token] operatorAssociativity] == DDOperatorAssociativityLeft) {
+ *error = ERR(DDErrorCodeUnaryOperatorMissingLeftOperand, @"no left operand to unary %@", [self token]);
+ } else {
+ *error = ERR(DDErrorCodeUnaryOperatorMissingRightOperand, @"no right operand to unary %@", [self token]);
+ }
+ } else {
+ *error = ERR(DDErrorCodeOperatorMissingOperands, @"missing operands for operator: %@", [self token]);
+ }
return NO;
}

0 comments on commit 4636edb

Please sign in to comment.