From 4ccd1811b011cdb665470b6442168f94336c9ffb Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 5 Mar 2025 15:24:10 -0800 Subject: [PATCH] Bug Fix: Correct exception handling blocks These should be catching NSException*, not generic `id`. Signed-off-by: Christopher Snowhill --- Application/AppController.m | 2 +- Audio/AudioPlayer.m | 4 ++-- Audio/Plugin.h | 2 +- Playlist/PlaylistController.m | 6 +++--- Playlist/PlaylistLoader.m | 36 +++++++++++++++++------------------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Application/AppController.m b/Application/AppController.m index 654a8bc41..b18935f34 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -859,7 +859,7 @@ static BOOL consentLastEnabled = NO; @try { [playlistView selectRowIndexes:[NSIndexSet indexSetWithIndex:pe.index] byExtendingSelection:NO]; } - @catch(id anException) { + @catch(NSException *e) { } } diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index 38a6c0104..1c8c5c432 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -422,8 +422,8 @@ } } } - @catch(id anException) { - DLog(@"Exception thrown checking file match: %@", anException); + @catch(NSException *e) { + DLog(@"Exception thrown checking file match: %@", e); } } diff --git a/Audio/Plugin.h b/Audio/Plugin.h index c88eeb942..ef31333b1 100644 --- a/Audio/Plugin.h +++ b/Audio/Plugin.h @@ -111,7 +111,7 @@ static NSString *guess_encoding_of_string(const char *input) { @try { ret = [NSString stringWithUTF8String:input]; } - @catch(id anException) { + @catch(NSException *e) { // This method is incredibly slow NSData *stringData = [NSData dataWithBytes:input length:strlen(input)]; [NSString stringEncodingForData:stringData encodingOptions:nil convertedString:&ret usedLossyConversion:nil]; diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index a9f756cc5..c61fe26f1 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -969,15 +969,15 @@ static void *playlistControllerContext = &playlistControllerContext; @try { [super insertObjects:objects atArrangedObjectIndexes:indexes]; } - @catch(id anException) { + @catch(NSException *e) { // Even further bodge fix @try { count = [[self arrangedObjects] count]; indexes = [NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(count, [objects count])]; [super insertObjects:objects atArrangedObjectIndexes:indexes]; } - @catch(id anException) { - DLog(@"Exception thrown adding tracks to the playlist: %@", anException); + @catch(NSException *e) { + DLog(@"Exception thrown adding tracks to the playlist: %@", e); } } diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index a992666b6..4ac0f1bbc 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -402,9 +402,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc [pathTask finish]; } - @catch(id anException) { - DLog(@"Exception caught while processing path: %@", anException); - [SentrySDK captureException:anException]; + @catch(NSException *e) { + DLog(@"Exception caught while processing path: %@", e); + [SentrySDK captureException:e]; [pathTask finishWithStatus:kSentrySpanStatusInternalError]; } @@ -518,9 +518,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc pathTask = nil; } } - @catch(id anException) { - DLog(@"Exception caught while processing for containers: %@", anException); - [SentrySDK captureException:anException]; + @catch(NSException *e) { + DLog(@"Exception caught while processing for containers: %@", e); + [SentrySDK captureException:e]; if(innerTask) { [innerTask finishWithStatus:kSentrySpanStatusInternalError]; } @@ -600,9 +600,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc [fileTask finish]; } - @catch(id anException) { - DLog(@"Exception caught while filtering paths: %@", anException); - [SentrySDK captureException:anException]; + @catch(NSException *e) { + DLog(@"Exception caught while filtering paths: %@", e); + [SentrySDK captureException:e]; if(fileTask) { [fileTask finishWithStatus:kSentrySpanStatusInternalError]; } @@ -657,9 +657,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc [containedUrlTask finish]; } - @catch(id anException) { - DLog(@"Exception caught filtering contained URL: %@", anException); - [SentrySDK captureException:anException]; + @catch(NSException *e) { + DLog(@"Exception caught filtering contained URL: %@", e); + [SentrySDK captureException:e]; if(containedUrlTask) { [containedUrlTask finishWithStatus:kSentrySpanStatusInternalError]; } @@ -926,9 +926,9 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path); [childTask finish]; } } - @catch(id anException) { - DLog(@"Exception thrown while reading tags: %@", anException); - [SentrySDK captureException:anException]; + @catch(NSException *e) { + DLog(@"Exception thrown while reading tags: %@", e); + [SentrySDK captureException:e]; if(childTask) { [childTask finishWithStatus:kSentrySpanStatusInternalError]; } @@ -1074,9 +1074,9 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path); [childTask finish]; } } - @catch(id anException) { - DLog(@"Exception thrown while reading tag synchronously: %@", anException); - [SentrySDK captureException:anException]; + @catch(NSException *e) { + DLog(@"Exception thrown while reading tag synchronously: %@", e); + [SentrySDK captureException:e]; if(childTask) { [childTask finishWithStatus:kSentrySpanStatusInternalError]; }