Changes to config-file structure.
5 // Created by Jens Alfke on 2/25/09.
6 // Copyright 2009 Jens Alfke. All rights reserved.
9 #import <Foundation/NSObject.h>
10 @class NSError, NSString;
13 extern NSString* const MYErrorDomain;
16 /** "Miscellaneous" error code, set by MYMiscError.
17 Handy during development, but before shipping you really should define
18 individual error codes for each error condition. */
19 kMYErrorMisc = 999999,
23 /** Creates an NSError in MYErrorDomain. */
24 NSError *MYError( int errorCode, NSString *domain, NSString *messageFormat, ... )
25 __attribute__ ((format (__NSString__, 3, 4)));
27 /** A variant of MYError, useful for returning from a method.
28 If errorCode is nonzero, constructs an NSError and stores it into *outError,
29 then returns NO. Otherwise returns YES. */
30 BOOL MYReturnError( NSError **outError,
31 int errorCode, NSString *domain, NSString *messageFormat, ... )
32 __attribute__ ((format (__NSString__, 4, 5)));
34 /** Convenience function for creating NSErrors.
35 Stores an NSError into *error, and returns NO.
36 Domain will be MYErrorDomain, code will be kMYErrorMisc.
37 Handy during development, but before shipping you really should define
38 individual error codes for each error condition. */
39 BOOL MYMiscError( NSError **outError, NSString *messageFormat, ... )
40 __attribute__ ((format (__NSString__, 2, 3)));
42 NSString* MYPrintableErrorCode( int code );
43 NSString* MYErrorName( NSString *domain, int code );
45 @interface NSError (MYUtilities)
46 /** Prepends a message to the beginning of the receiver's existing message,
47 and returns the modified NSError. */
48 - (NSError*) my_errorByPrependingMessage: (NSString*)message;
50 - (NSString*) my_nameOfCode;