//
//  URLUtils.m
//  Cloudy
//
//  Created by Jens Alfke on 4/28/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "URLUtils.h"


@implementation NSHTTPURLResponse (MYUtilities)


- (NSError*) HTTPError
{
    // HTTP status >= 300 is considered an error:
    int status = self.statusCode;
    if( status >= 300 ) {
        NSString *reason = NSLocalizedStringFromTable( @"HTTP_ERROR_MESSAGE",@"UKCrashReporter",@"");
        reason = [NSHTTPURLResponse localizedStringForStatusCode: status];
        NSDictionary *info = $dict({NSLocalizedFailureReasonErrorKey,reason});
        return [NSError errorWithDomain: MyHTTPErrorDomain code: status userInfo: info];
    } else
        return nil;
}


NSString* const MyHTTPErrorDomain = @"HTTP";


@end
