passepartoutvpn / tunnelkit

VPN client library for Apple platforms.
GNU General Public License v3.0
9 stars 8 forks source link

Fix keychain error escaping catch block #326

Closed keeshux closed 1 year ago

keeshux commented 1 year ago

When setting a keychain password, there is a specific catch block for KeychainError. That is, when looking for an existing password, we want to keep going when well-known errors (KeychainError) are thrown, and rethrow any other error.

However, in #325, Keychain.password() throws instances of TunnelKitManagerError, thus escaping the KeychainError catch block. The nasty effect of this is that if we fail to find an existing password, the method may rethrow immediately and fail to set a password.

Bottom line: Swift untyped error handling sucks.

Fixes #327