//
//  OxNSDocument.m
//  Flash2
//
//  Copyright 2008 Nicholas Matsakis. 
//  The code in thie file is released to the public under the
//  terms of the MIT License as described here:
//  http://www.opensource.org/licenses/mit-license.php
//

#import "OxNSDocument.h"

@implementation NSDocument (Oaxaca2)

- (void) presentErrorMessage:(NSString*)format, ...
{
    va_list ap;
    va_start(ap, format);    
    NSString *lformat = NSLocalizedString(format, @"");
    NSString *msg = [[[NSString alloc] initWithFormat:lformat arguments:ap] autorelease];
    va_end(ap);
    
    [self presentErrorInDomain:DEFAULT_ERROR_DOMAIN
                          code:0
                       message:@"%@", msg];
}

- (void) presentErrorInDomain:(NSString*)domain 
                         code:(int)code
                      message:(NSString*)format, ...
{
    va_list ap;
    va_start(ap, format);    
    NSString *lformat = NSLocalizedString(format, @"");
    NSString *msg = [[[NSString alloc] initWithFormat:lformat arguments:ap] autorelease];
    va_end(ap);
    
    NSDictionary *errorDict = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedDescriptionKey];
    
    NSError *error = [NSError errorWithDomain:domain
                                         code:code
                                     userInfo:errorDict];
    
    [self presentError:error];
}

@end
