#import "Finch-Reporter.h"

/*
    The dummyError trick is here to safely initialize
    the NSError** output variable passed to various methods
    that use the Reporter class. Discussion here:
    http://google.com/search?q=should+method+set+nserror
*/

@implementation FinchReporter

#pragma mark Initialization

- (id) initWithDomain: (NSString*) errDomain error: (NSError**) error
{
    self = [super init];
    domain = errDomain;//[errDomain retain]; ARC dumb
    if (error == NULL)
        error = nil;
    return self;
}

+ (id) forDomain: (NSString*) errDomain error: (NSError**) error
{
    return [[self alloc] initWithDomain:errDomain error:error];
}

- (void) dealloc
{
    //[domain release]; ARC dumb
    //[super dealloc]; ARC dumb
}

#pragma mark Error Reporting

- (NSError*) errorWithCode: (int) code
{
    return [NSError errorWithDomain:domain code:code userInfo:nil];
}

- (NSError*) errorWithCode: (int) code description: (NSString*) msg
{
    return [NSError errorWithDomain:domain code:code
        userInfo:[NSDictionary dictionaryWithObject:msg
            forKey:NSLocalizedDescriptionKey]];
}

@end
