MYErrorUtils.h
author snej@snej.local
Sat Apr 04 20:53:53 2009 -0700 (2009-04-04)
changeset 22 a9da6c5d3f7c
child 23 a910102a1c9d
permissions -rw-r--r--
* Added MYErrorUtils
* Added AssertAbstractMethod() to Test
* Added .xcconfig files
snej@22
     1
//
snej@22
     2
//  MYErrorUtils.h
snej@22
     3
//  MYCrypto
snej@22
     4
//
snej@22
     5
//  Created by Jens Alfke on 2/25/09.
snej@22
     6
//  Copyright 2009 Jens Alfke. All rights reserved.
snej@22
     7
//
snej@22
     8
snej@22
     9
#import <Foundation/NSObject.h>
snej@22
    10
@class NSError, NSString;
snej@22
    11
snej@22
    12
snej@22
    13
extern NSString* const MYErrorDomain;
snej@22
    14
snej@22
    15
enum {
snej@22
    16
    /** "Miscellaneous" error code, set by MYMiscError.
snej@22
    17
        Handy during development, but before shipping you really should define
snej@22
    18
        individual error codes for each error condition. */
snej@22
    19
    kMYErrorMisc = 999999,
snej@22
    20
};
snej@22
    21
snej@22
    22
snej@22
    23
/** Creates an NSError in MYErrorDomain. */
snej@22
    24
NSError *MYError( int errorCode, NSString *domain, NSString *messageFormat, ... ) 
snej@22
    25
                                __attribute__ ((format (__NSString__, 3, 4)));
snej@22
    26
snej@22
    27
/** Convenience function for creating NSErrors.
snej@22
    28
    Stores an NSError into *error, and returns NO.
snej@22
    29
    Domain will be MYErrorDomain, code will be kMYErrorMisc.
snej@22
    30
    Handy during development, but before shipping you really should define
snej@22
    31
    individual error codes for each error condition. */
snej@22
    32
BOOL MYMiscError( NSError **outError, NSString *messageFormat, ... )
snej@22
    33
                                __attribute__ ((format (__NSString__, 2, 3)));
snej@22
    34
snej@22
    35
NSString* MYPrintableErrorCode( int code );
snej@22
    36
NSString* MYErrorName( NSString *domain, int code );
snej@22
    37
snej@22
    38
@interface NSError (MYUtilities)
snej@22
    39
/** Prepends a message to the beginning of the receiver's existing message,
snej@22
    40
    and returns the modified NSError. */
snej@22
    41
- (NSError*) my_errorByPrependingMessage: (NSString*)message;
snej@22
    42
snej@22
    43
- (NSString*) my_nameOfCode;
snej@22
    44
snej@22
    45
@end