Handle Objective-C exceptions properly
@@ -204,17 +204,16 @@ import TrueTime
}
private let exceptionHandler: Void = NSSetUncaughtExceptionHandler { (exception) in
- DispatchQueue.main.async {
- let alert = UIAlertController(title: "\(exception.name.rawValue)", message: exception.reason, preferredStyle: .alert)
- alert.addAction(UIAlertAction(title: Localizable.ok, style: .cancel, handler: nil))
- for scene in UIApplication.shared.connectedScenes {
- if scene.activationState == .foregroundActive {
- (scene as? UIWindowScene)?.windows.first?.topViewController?.present(alert, animated: true, completion: nil)
- break
- }
+ PyOutputHelper.printError("\(exception.callStackSymbols.joined(separator: "\n"))\n\n\(exception.name.rawValue): \(exception.reason ?? "")\n", script: nil)
+
+ for script in Python.shared.runningScripts {
+ if let path = script as? String {
+ Python.shared.stop(script: path)
}
}
+ Python.shared.runningScripts = NSArray(array: [])
+
if !Thread.current.isMainThread {
DispatchSemaphore(value: 0).wait()
}
