1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/URLUtils.m Tue May 20 17:40:28 2008 -0700
1.3 @@ -0,0 +1,32 @@
1.4 +//
1.5 +// URLUtils.m
1.6 +// Cloudy
1.7 +//
1.8 +// Created by Jens Alfke on 4/28/08.
1.9 +// Copyright 2008 __MyCompanyName__. All rights reserved.
1.10 +//
1.11 +
1.12 +#import "URLUtils.h"
1.13 +
1.14 +
1.15 +@implementation NSHTTPURLResponse (MYUtilities)
1.16 +
1.17 +
1.18 +- (NSError*) HTTPError
1.19 +{
1.20 + // HTTP status >= 300 is considered an error:
1.21 + int status = self.statusCode;
1.22 + if( status >= 300 ) {
1.23 + NSString *reason = NSLocalizedStringFromTable( @"HTTP_ERROR_MESSAGE",@"UKCrashReporter",@"");
1.24 + reason = [NSHTTPURLResponse localizedStringForStatusCode: status];
1.25 + NSDictionary *info = $dict({NSLocalizedFailureReasonErrorKey,reason});
1.26 + return [NSError errorWithDomain: MyHTTPErrorDomain code: status userInfo: info];
1.27 + } else
1.28 + return nil;
1.29 +}
1.30 +
1.31 +
1.32 +NSString* const MyHTTPErrorDomain = @"HTTP";
1.33 +
1.34 +
1.35 +@end