Instantly share code, notes, and snippets.

Embed
What would you like to do?
Some Error can be catch but not thrown
import StoreKit
//extension SKError: Error { } // Uncomment this line to make it throwable
func throwError() throws {
throw SKError.unknown // Can not be thrown. Thrown error code type 'SKError.Code' does not conform to 'Error'
}
do {
try throwError()
} catch {
switch error {
case SKError.unknown: // Can be catch
break
default:
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment