]> git.saurik.com Git - apple/security.git/blob - KeychainCircle/KCError.m
Security-58286.220.15.tar.gz
[apple/security.git] / KeychainCircle / KCError.m
1 //
2 // KCError.m
3 // Security
4 //
5 //
6
7 #import "KCError.h"
8
9 static NSString* KCErrorDomain = @"com.apple.security.keychaincircle";
10
11
12 @implementation NSError(KCJoiningError)
13
14 + (nonnull instancetype) errorWithJoiningError:(KCJoiningError) code
15 format:(NSString*) format
16 arguments:(va_list) va {
17 return [[NSError alloc] initWithJoiningError:code
18 userInfo:@{NSLocalizedDescriptionKey:[[NSString alloc] initWithFormat:format arguments:va]}];
19
20 }
21
22 + (nonnull instancetype) errorWithJoiningError:(KCJoiningError) code
23 format:(NSString*) format, ... {
24
25 va_list va;
26 va_start(va, format);
27 NSError* result = [NSError errorWithJoiningError:code format:format arguments:va];
28 va_end(va);
29
30 return result;
31
32 }
33 - (nonnull instancetype) initWithJoiningError:(KCJoiningError) code
34 userInfo:(nonnull NSDictionary *)dict {
35 return [self initWithDomain:KCErrorDomain code:code userInfo:dict];
36 }
37 @end
38
39 void KCJoiningErrorCreate(KCJoiningError code, NSError** error, NSString* format, ...) {
40 if (error && (*error == nil)) {
41 va_list va;
42 va_start(va, format);
43 *error = [NSError errorWithJoiningError:code format:format arguments:va];
44 va_end(va);
45 }
46 }
47