Add error-code property for ParseError token

In addition to the detailed reason message parse errors have an
error-code property that is specified in the WHATWG HTML spec.
This commit is contained in:
iska
2017-09-07 22:08:28 +02:00
parent 6dee6c1e74
commit d4ff2e3869
2 changed files with 16 additions and 10 deletions
+8 -5
View File
@@ -10,21 +10,24 @@
@interface HTMLParseErrorToken ()
{
NSString *_reason;
NSString *_code;
NSString *_details;
NSUInteger _location;
}
@end
@implementation HTMLParseErrorToken
@synthesize reason = _reason;
@synthesize code = _code;
@synthesize details = _details;
@synthesize location = _location;
- (instancetype)initWithReasonMessage:(NSString *)reason andStreamLocation:(NSUInteger)location
- (instancetype)initWithCode:(NSString *)code details:(NSString *)details location:(NSUInteger)location
{
self = [super init];
if (self) {
self.type = HTMLTokenTypeParseError;
_reason = [reason copy];
_code = [code copy];
_details = [details copy];
_location = location;
}
return self;
@@ -32,7 +35,7 @@
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p Reason='%@' Location='%lu'>", self.class, self, _reason, (unsigned long)_location];
return [NSString stringWithFormat:@"<%@: %p Code='%@' Details='%@' Location='%lu'>", self.class, self, _code, _details, (unsigned long)_location];
}
@end