try-catch exceptions in Swift [duplicate]
问题 This question already has answers here : Error-Handling in Swift-Language (12 answers) Closed 5 years ago . Is it possible to catch exceptions in Swift? Given the following code: NSException.raise(NSRangeException, format: "Now you've gone too far!", arguments: CVaListPointer(fromUnsafePointer: UnsafePointer())) Is it possible to prevent the exception from crashing the entire program? That is, what is the Swift equivalent of the following in Objective-C: @try { [NSException raise