I know there is an UncaughtExceptionHandler in Cocoa, However I am looking for same thing for Swift. i.e. whenever there is any error/exception in application which is not caught locally there due to any mistake, it should bubble all the way to the top level application object where I should be able to gracefully handle it and respond to user appropriately.
Android has it. Flex has it. Java has it. Wondering why Swift is missing this key feature.
import UIKit import CoreData
class ViewController: UIViewController {
var result = NSArray()
}
Swift has no mechanism to catch all arbitrary runtime exceptions. The reasons are explained in
in the swift-users forum. Extract:
For more information, see
This is the code I use to log all exceptions/errors.
Log.error(with:)
is a custom function where I store the stack trace, along with other info.Thread.callStackSymbols
is an array of strings and represents the stack trace.