2 // NSError+KCCreationHelpers.h
7 #import <Foundation/Foundation.h>
9 NS_ASSUME_NONNULL_BEGIN
11 // Returns false and fills in error with formatted description if cc_result is an error
12 bool CoreCryptoError(int cc_result
, NSError
* _Nullable
* _Nullable error
, NSString
* _Nonnull description
, ...) NS_FORMAT_FUNCTION(3, 4);
13 // Returns false and fills in a requirement error if requirement is false
14 // We should have something better than -50 here.
15 bool RequirementError(bool requirement
, NSError
* _Nullable
* _Nullable error
, NSString
* _Nonnull description
, ...) NS_FORMAT_FUNCTION(3, 4);
17 bool OSStatusError(OSStatus status
, NSError
* _Nullable
* _Nullable error
, NSString
* _Nonnull description
, ...) NS_FORMAT_FUNCTION(3, 4);
20 // MARK: Error Extensions
21 @interface
NSError(KCCreationHelpers
)
23 + (instancetype
) errorWithOSStatus
:(OSStatus
) status
24 userInfo
:(NSDictionary
*)dict
;
26 - (instancetype
) initWithOSStatus
:(OSStatus
) status
27 userInfo
:(NSDictionary
*)dict
;
29 + (instancetype
) errorWithOSStatus
:(OSStatus
) status
30 description
:(NSString
*)description
31 args
:(va_list)va
NS_FORMAT_FUNCTION(2, 0);
33 - (instancetype
) initWithOSStatus
:(OSStatus
) status
34 description
:(NSString
*)description
35 args
:(va_list)va
NS_FORMAT_FUNCTION(2, 0);
37 + (instancetype
) errorWithCoreCryptoStatus
:(int) status
38 userInfo
:(NSDictionary
*)dict
;
40 - (instancetype
) initWithCoreCryptoStatus
:(int) status
41 userInfo
:(NSDictionary
*)dict
;
43 + (instancetype
) errorWithCoreCryptoStatus
:(int) status
44 description
:(NSString
*)description
45 args
:(va_list)va
NS_FORMAT_FUNCTION(2, 0);
47 - (instancetype
) initWithCoreCryptoStatus
:(int) status
48 description
:(NSString
*)description
49 args
:(va_list)va
NS_FORMAT_FUNCTION(2, 0);