URLUtils.m
author Jens Alfke <jens@mooseyard.com>
Sun Jul 13 10:45:42 2008 -0700 (2008-07-13)
changeset 16 ce9c83f7ec14
parent 7 59addced5e2a
child 17 a1044ae95953
permissions -rw-r--r--
* Minor fixes to glitches detected by the clang static analyzer.
* Added MYAnimatingSplitView class.
     1 //
     2 //  URLUtils.m
     3 //  MYUtilities
     4 //
     5 //  Created by Jens Alfke on 4/28/08.
     6 //  Copyright 2008 Jens Alfke. 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
    33 
    34 
    35 /*
    36  Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    37  
    38  Redistribution and use in source and binary forms, with or without modification, are permitted
    39  provided that the following conditions are met:
    40  
    41  * Redistributions of source code must retain the above copyright notice, this list of conditions
    42  and the following disclaimer.
    43  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
    44  and the following disclaimer in the documentation and/or other materials provided with the
    45  distribution.
    46  
    47  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    48  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
    49  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
    50  BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    51  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
    52   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    53  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
    54  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    55  */