From 762d298c06e7259f8de5f872b417319e9f993a0a Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 19 Feb 2023 14:19:39 -0500 Subject: [PATCH] Report caught NSExceptions to Sentry --- Tusker/AppDelegate.swift | 3 +++ Tusker/Scenes/TuskerSceneDelegate.swift | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Tusker/AppDelegate.swift b/Tusker/AppDelegate.swift index a7700a2d..5ffd44e7 100644 --- a/Tusker/AppDelegate.swift +++ b/Tusker/AppDelegate.swift @@ -151,6 +151,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { original(self, selector, sender) } } + if let exception { + SentrySDK.capture(exception: exception) + } } as @convention(block) (UIStatusBarManager, AnyObject) -> Void) originalIMP = class_replaceMethod(UIStatusBarManager.self, selector, imp, "v@:@") if originalIMP == nil { diff --git a/Tusker/Scenes/TuskerSceneDelegate.swift b/Tusker/Scenes/TuskerSceneDelegate.swift index 6067109a..df53630b 100644 --- a/Tusker/Scenes/TuskerSceneDelegate.swift +++ b/Tusker/Scenes/TuskerSceneDelegate.swift @@ -7,6 +7,7 @@ // import UIKit +import Sentry protocol TuskerSceneDelegate: UISceneDelegate { var window: UIWindow? { get } @@ -31,11 +32,14 @@ extension TuskerSceneDelegate { guard let window else { return } window.overrideUserInterfaceStyle = Preferences.shared.theme window.tintColor = Preferences.shared.accentColor.color - _ = catchNSException { + let exception = catchNSException { let key = ["Controller", "Presentation", "root", "_"].reversed().joined() if let rootPresentationController = window.value(forKey: key) as? UIPresentationController { rootPresentationController.overrideTraitCollection = UITraitCollection(pureBlackDarkMode: Preferences.shared.pureBlackDarkMode) } } + if let exception { + SentrySDK.capture(exception: exception) + } } }