diff -r 000000000000 -r 82a37ccf6b8c URLUtils.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/URLUtils.m Tue May 20 17:40:28 2008 -0700 @@ -0,0 +1,32 @@ +// +// 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