1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

#[cfg(feature = "NSString")]
pub type NSErrorDomain = NSString;

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSCocoaErrorDomain: &'static NSErrorDomain;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPOSIXErrorDomain: &'static NSErrorDomain;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSOSStatusErrorDomain: &'static NSErrorDomain;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSMachErrorDomain: &'static NSErrorDomain;
}

#[cfg(feature = "NSString")]
pub type NSErrorUserInfoKey = NSString;

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSUnderlyingErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSMultipleUnderlyingErrorsKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSLocalizedDescriptionKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSLocalizedFailureReasonErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSLocalizedRecoverySuggestionErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSLocalizedRecoveryOptionsErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSRecoveryAttempterErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSHelpAnchorErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSDebugDescriptionErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSLocalizedFailureErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSStringEncodingErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSURLErrorKey: &'static NSErrorUserInfoKey;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSFilePathErrorKey: &'static NSErrorUserInfoKey;
}

extern_class!(
    #[derive(PartialEq, Eq, Hash)]
    pub struct NSError;

    unsafe impl ClassType for NSError {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl Send for NSError {}

unsafe impl Sync for NSError {}

#[cfg(feature = "NSObject")]
unsafe impl NSCoding for NSError {}

#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSError {}

unsafe impl NSObjectProtocol for NSError {}

#[cfg(feature = "NSObject")]
unsafe impl NSSecureCoding for NSError {}

extern_methods!(
    unsafe impl NSError {
        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method_id(@__retain_semantics Init initWithDomain:code:userInfo:)]
        pub unsafe fn initWithDomain_code_userInfo(
            this: Allocated<Self>,
            domain: &NSErrorDomain,
            code: NSInteger,
            dict: Option<&NSDictionary<NSErrorUserInfoKey, AnyObject>>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method_id(@__retain_semantics Other errorWithDomain:code:userInfo:)]
        pub unsafe fn errorWithDomain_code_userInfo(
            domain: &NSErrorDomain,
            code: NSInteger,
            dict: Option<&NSDictionary<NSErrorUserInfoKey, AnyObject>>,
        ) -> Retained<Self>;

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other domain)]
        pub fn domain(&self) -> Retained<NSErrorDomain>;

        #[method(code)]
        pub fn code(&self) -> NSInteger;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method_id(@__retain_semantics Other userInfo)]
        pub fn userInfo(&self) -> Retained<NSDictionary<NSErrorUserInfoKey, AnyObject>>;

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other localizedDescription)]
        pub fn localizedDescription(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other localizedFailureReason)]
        pub unsafe fn localizedFailureReason(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other localizedRecoverySuggestion)]
        pub unsafe fn localizedRecoverySuggestion(&self) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other localizedRecoveryOptions)]
        pub unsafe fn localizedRecoveryOptions(&self) -> Option<Retained<NSArray<NSString>>>;

        #[method_id(@__retain_semantics Other recoveryAttempter)]
        pub unsafe fn recoveryAttempter(&self) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other helpAnchor)]
        pub unsafe fn helpAnchor(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSArray")]
        #[method_id(@__retain_semantics Other underlyingErrors)]
        pub unsafe fn underlyingErrors(&self) -> Retained<NSArray<NSError>>;

        #[cfg(all(feature = "NSString", feature = "block2"))]
        #[method(setUserInfoValueProviderForDomain:provider:)]
        pub unsafe fn setUserInfoValueProviderForDomain_provider(
            error_domain: &NSErrorDomain,
            provider: Option<
                &block2::Block<
                    dyn Fn(NonNull<NSError>, NonNull<NSErrorUserInfoKey>) -> *mut AnyObject,
                >,
            >,
        );

        #[cfg(all(feature = "NSString", feature = "block2"))]
        #[method(userInfoValueProviderForDomain:)]
        pub unsafe fn userInfoValueProviderForDomain(
            error_domain: &NSErrorDomain,
        ) -> *mut block2::Block<
            dyn Fn(NonNull<NSError>, NonNull<NSErrorUserInfoKey>) -> *mut AnyObject,
        >;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSError {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    }
);

extern_category!(
    /// Category "NSErrorRecoveryAttempting" on [`NSObject`].
    #[doc(alias = "NSErrorRecoveryAttempting")]
    pub unsafe trait NSObjectNSErrorRecoveryAttempting {
        #[method(attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:)]
        unsafe fn attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo(
            &self,
            error: &NSError,
            recovery_option_index: NSUInteger,
            delegate: Option<&AnyObject>,
            did_recover_selector: Option<Sel>,
            context_info: *mut c_void,
        );

        #[method(attemptRecoveryFromError:optionIndex:)]
        unsafe fn attemptRecoveryFromError_optionIndex(
            &self,
            error: &NSError,
            recovery_option_index: NSUInteger,
        ) -> bool;
    }

    unsafe impl NSObjectNSErrorRecoveryAttempting for NSObject {}
);