diff --git a/FBControlCore/Crashes/FBCrashLogNotifier.h b/FBControlCore/Crashes/FBCrashLogNotifier.h index 21b9500b3..26ebdd47e 100644 --- a/FBControlCore/Crashes/FBCrashLogNotifier.h +++ b/FBControlCore/Crashes/FBCrashLogNotifier.h @@ -37,9 +37,9 @@ NS_ASSUME_NONNULL_BEGIN Starts listening for crash logs. @param onlyNew YES if you only want to ingest crash logs from now, NO to ingest from the beginning of time. - @return the receiver, for chaining. + @return success. */ -- (instancetype)startListening:(BOOL)onlyNew; +- (BOOL)startListening:(BOOL)onlyNew; /** Obtains the next crash log, for a given predicate. diff --git a/FBControlCore/Crashes/FBCrashLogNotifier.m b/FBControlCore/Crashes/FBCrashLogNotifier.m index be5cc8de3..585ef0315 100644 --- a/FBControlCore/Crashes/FBCrashLogNotifier.m +++ b/FBControlCore/Crashes/FBCrashLogNotifier.m @@ -88,10 +88,10 @@ - (instancetype)initWithDirectories:(NSArray *)directories store:(FB return self; } -- (void)startListening:(BOOL)onlyNew +- (BOOL)startListening:(BOOL)onlyNew { if (self.eventStream) { - return; + return YES; } FSEventStreamContext context = { @@ -120,8 +120,13 @@ - (void)startListening:(BOOL)onlyNew ); FSEventStreamSetDispatchQueue(eventStream, self.queue); Boolean started = FSEventStreamStart(eventStream); - NSAssert(started, @"Event Stream could not be started"); + if (!started) { + NSLog(@"FS Event Stream could not be started"); + return NO; + } + self.eventStream = eventStream; + return YES; } @end @@ -172,19 +177,23 @@ + (instancetype)sharedInstance #pragma mark Public Methods -- (instancetype)startListening:(BOOL)onlyNew +- (BOOL)startListening:(BOOL)onlyNew { #if defined(__apple_build_version__) - [self.fsEvents startListening:onlyNew]; + return [self.fsEvents startListening:onlyNew]; #else self.sinceDate = NSDate.date; + return YES; #endif - return self; } - (FBFuture *)nextCrashLogForPredicate:(NSPredicate *)predicate { - [self startListening:YES]; + if (![self startListening:YES]) { + return [[FBControlCoreError + describeFormat:@"Crash Log Info could not be obtained"] + failFuture]; + } #if defined(__apple_build_version__) return [FBCrashLogNotifier.sharedInstance.fsEvents.store nextCrashLogForMatchingPredicate:predicate];