Skip to content

Instantly share code, notes, and snippets.

@ileitch
Created September 13, 2018 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ileitch/d3c4d749655543139fb7e0484543b626 to your computer and use it in GitHub Desktop.
Save ileitch/d3c4d749655543139fb7e0484543b626 to your computer and use it in GitHub Desktop.
import Foundation
import XCTest
enum AnError: Error {
case boom
}
class LogCrashTest: XCTestCase {
func testUnderlyingSwiftError() {
let userInfo: [String: Any] = [
NSUnderlyingErrorKey: AnError.boom,
NSLocalizedDescriptionKey: "Hello",
]
let nsError = NSError(domain: "Error", code: 0, userInfo: userInfo)
let swiftError = nsError as Error
// Crashes with -[_SwiftValue userInfo]: unrecognized selector sent to instance
print("Error: \(swiftError)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment