hyperledger-archives / indy-sdk

indy-sdk
https://wiki.hyperledger.org/display/indy
Apache License 2.0
669 stars 736 forks source link

fix(objective c wrapper) NSError should be nil when there is no error #2440

Closed conanoc closed 9 months ago

conanoc commented 3 years ago

Signed-off-by: conanoc conanoc@gmail.com

Returning NSError with error code Success makes trouble sometimes. The following code snippet opens a wallet using async/await in swift5. It always throws error and does not return wallet handle because the error included in the completion handler is not nil.

    let wallet = IndyWallet.sharedInstance()!
    var walletHandle : IndyHandle?
    do {
        walletHandle = try await wallet.open(withConfig: walletConfig, credentials: walletCredentials)
    } catch {
        if let err = error as NSError? {
            print("Cannot open wallet: \(err.userInfo["message"] ?? "Unknown error")")
        }
        return
    }

So, NSError should be nil when the indy_error_code is Success.

WadeBarnes commented 2 years ago

@mirgee, Is this something you could review?