You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When bridging from a Swift Promise to an Objective-C AnyPromise the catch block in objc-c is not invoked when a Swift Error is thrown and PMKWhen is used around the AnyPromise.
Example:
Swift:
enum MyError: Error {
case PromiseError()
}
@objc class MyClass: NSObject {
@objc class func promise() -> AnyPromise {
let promise: Promise<String> = Promise(resolvers: { _, reject in
reject(MyError.PromiseError())
}).recover(execute: { error -> String in
print("Swift Error")
throw error
})
return AnyPromise(promise)
}
}
When bridging from a Swift
Promise
to an Objective-CAnyPromise
thecatch
block in objc-c is not invoked when a SwiftError
is thrown andPMKWhen
is used around the AnyPromise.Example:
Swift:
Objective-c:
Instead of executing the
catch
block of Objective-c it calls thesuccess
block. This print the following:A workaround is to rethrow the Swift error as an
NSError
:In that case the
catch
block is executed and will print the following:The text was updated successfully, but these errors were encountered: