//
//  EXPError.m
//  dde
//
//  Created by Ashley on 21/07/2007.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "EXPError.h"

@implementation EXPError

- (id) init
{
	self = [super init];
	if (self!=nil) {
		_maxErrors = 10;
		_errors = [[NSMutableArray alloc] init];
	}
	
	return self;
}

- (BOOL) addError:(NSString *)message atLine:(int)lineNumber
{
	printf("\nError %s at line %d.\n", [message UTF8String], lineNumber);
	NSNumber *num = [[NSNumber alloc] initWithInt:lineNumber];
	NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:message, @"Message", num, @"Line", nil];
	[num release];
	[_errors addObject:dict];
	[dict release];
	
	return ([_errors count]<=_maxErrors);
}

- (NSMutableArray *) errors
{
	return _errors;
}

- (int) numErrors
{
	return [[self errors] count];
}

- (void) dealloc
{
	[_errors release];
	[super dealloc];
}

@end