Created
September 13, 2018 20:21
-
-
Save ileitch/d3c4d749655543139fb7e0484543b626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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