I'm integrating PromiseKit into our current system and I need the catch
part of the chain to use 2 arguments. I'd like my catch to use error, fetcher
instead of just error. What is the best way to do this?
infoPromise.then { objects in
print(objects)
}.catch { error in /* error, fetcher in */
print(error)
}
I've thought of including the fetcher
as part of the userInfo
dictionary on NSError
, but I'd prefer it as a separate argument if possible.
Edit - More Info:
Here is the adapter I'm using. The fetcher
is returned in the onError
from my existing system.
- (AnyPromise *)fetchAll:(NSString *)entityName {
return [AnyPromise promiseWithAdapterBlock:^(PMKAdapter _Nonnull adapter) {
[self fetchAll:entityName onComplete:^(NSArray *results) {
adapter(results,nil);
} onError:^(ICSHTTPFetcher *fetcher, NSError *error) {
adapter(nil,error);
}];
}];
}