Implemented Expression Evaluation/Parsing with Proper Error Handling
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// MPParseError.m
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 06.09.14.
|
||||
// Created by Kim Wittenburg on 08.09.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
@@ -10,19 +10,29 @@
|
||||
|
||||
@implementation MPParseError
|
||||
|
||||
- (instancetype)initWithErrorIndex:(NSUInteger)errorIndex errorMessageKey:(NSString *)errorMessageKey
|
||||
- (instancetype)initWithErrorRange:(NSRange)errorRange errorMessageKey:(NSString *)key
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_errorIndex = errorIndex;
|
||||
_localizedErrorMessage = NSLocalizedString(errorMessageKey, nil);
|
||||
_errorRange = errorRange;
|
||||
_localizedErrorMessage = NSLocalizedString(key, nil);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithErrorRange:(NSRange)errorRange localizederrorMessage:(NSString *)errorMessage
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_errorRange = errorRange;
|
||||
_localizedErrorMessage = errorMessage;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"MPParseError<at=%ld message=\"%@\">", self.errorIndex, self.localizedErrorMessage];
|
||||
return [NSString stringWithFormat:@"MPParseError<at=(%ld, %ld) message=\"%@\">", self.errorRange.location, self.errorRange.length, self.localizedErrorMessage];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user