Accessing code in Swift 3 Error
<p>New in Xcode 8 beta 4, <code>NSError</code> is bridged to the Swift <code>Error</code> protocol type. This affects StoreKit when dealing with failed <code>SKPaymentTransaction</code>s. You ought to check to be sure the error didn't occur because the transaction was cancelled to know whether or not to show an error message to the user. You do this by examining the error's <code>code</code>. But with <code>Error</code> instead of <code>NSError</code>, there is no <code>code</code> defined. I haven't been able to figure out how to properly get the error code from <code>Error</code>.</p>

<p>This worked in the previous version of Swift 3:</p>

<pre><code>func failedTransaction(_ transaction: SKPaymentTransaction) {
    if let transactionError = transaction.error {
        if transactionError.code != SKErrorCode.paymentCancelled.rawValue {
            //show error to user
        }
     }
     ...
}
</code></pre>

<p>Now that <code>error</code> is an <code>Error</code> not <code>NSError</code>, <code>code</code> is not a member.</p>