apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.46k stars 161 forks source link

Rename CryptoKit errors #274

Open 0xTim opened 3 weeks ago

0xTim commented 3 weeks ago

New API Proposal: CryptoError

Motivation:

CryptoKit errors are publicly exposed in the API which is confusing since from the outside CryptoKit is an implementation detail so it would be nice to rename this to reflect the name of the package. A typealias would help for those that want the backwards compatibility

Importance:

Not major but definitely a paper cut

Lukasa commented 3 weeks ago

The issue with renaming CryptoKitError is that on Apple platforms these errors actually come from CryptoKit. Changing the error there is pretty hard: it would represent an ABI break to rename completely, even with the typealias, so that’s not tenable, meaning there’d be two similar errors only one of which is thrown.

While I agree this is a paper cut, I don’t think this issue is severe enough to warrant a change. But I’d be happy to hear disagreement.

0xTim commented 3 weeks ago

Adding a typealias for CryptoKitError to CryptoError wouldn't break anything right? All the original stuff would continue to work but people using Swift Crypto would be able to catch and deal with CryptoErrors instead of knowing about CryptoKit

Lukasa commented 3 weeks ago

Yes, the typealias in the reverse direction will work.