URLUtils.m
author Jens Alfke <jens@mooseyard.com>
Fri May 02 12:49:43 2008 -0700 (2008-05-02)
changeset 7 59addced5e2a
child 11 e5976864dfe9
permissions -rw-r--r--
Added URLUtils. Rewrote Target.
     1 //
     2 //  URLUtils.m
     3 //  Cloudy
     4 //
     5 //  Created by Jens Alfke on 4/28/08.
     6 //  Copyright 2008 __MyCompanyName__. All rights reserved.
     7 //
     8 
     9 #import "URLUtils.h"
    10 
    11 
    12 @implementation NSHTTPURLResponse (MYUtilities)
    13 
    14 
    15 - (NSError*) HTTPError
    16 {
    17     // HTTP status >= 300 is considered an error:
    18     int status = self.statusCode;
    19     if( status >= 300 ) {
    20         NSString *reason = NSLocalizedStringFromTable( @"HTTP_ERROR_MESSAGE",@"UKCrashReporter",@"");
    21         reason = [NSHTTPURLResponse localizedStringForStatusCode: status];
    22         NSDictionary *info = $dict({NSLocalizedFailureReasonErrorKey,reason});
    23         return [NSError errorWithDomain: MyHTTPErrorDomain code: status userInfo: info];
    24     } else
    25         return nil;
    26 }
    27 
    28 
    29 NSString* const MyHTTPErrorDomain = @"HTTP";
    30 
    31 
    32 @end