diff --git a/Alcatraz/Controllers/ATZPluginWindowController.m b/Alcatraz/Controllers/ATZPluginWindowController.m index f50703a..94483eb 100644 --- a/Alcatraz/Controllers/ATZPluginWindowController.m +++ b/Alcatraz/Controllers/ATZPluginWindowController.m @@ -85,6 +85,18 @@ - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentN return YES; } +- (NSError *)willPresentError:(NSError *)error +{ + const NSUInteger maxLength = 500; + NSString *recoverySuggestion = error.userInfo[NSLocalizedRecoverySuggestionErrorKey]; + if (recoverySuggestion.length > maxLength) { + NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; + userInfo[NSLocalizedRecoverySuggestionErrorKey] = [[recoverySuggestion substringToIndex:MIN(maxLength, recoverySuggestion.length)] stringByAppendingString:@"…"]; + return [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; + } + return error; +} + #pragma mark - Bindings - (IBAction)installPressed:(ATZFillableButton *)button { diff --git a/Alcatraz/Helpers/ATZShell.m b/Alcatraz/Helpers/ATZShell.m index ada92b7..1d07003 100644 --- a/Alcatraz/Helpers/ATZShell.m +++ b/Alcatraz/Helpers/ATZShell.m @@ -77,10 +77,8 @@ - (void)setUpTerminationHandlerForTask:(NSTask *)task completion:(void(^)(NSStri if (task.terminationStatus == 0) { completion(output, nil); } else { - const NSUInteger maxLength = 500; - NSString *truncatedOutput = [[output substringToIndex:MIN(maxLength, output.length)] stringByAppendingString:output.length > maxLength ? @"…" : @""]; NSString *description = [NSString stringWithFormat:@"Task exited with status %d\n\n%@ %@", task.terminationStatus, task.launchPath, [task.arguments componentsJoinedByString:@" "]]; - NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: description, NSLocalizedRecoverySuggestionErrorKey: truncatedOutput }; + NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: description, NSLocalizedRecoverySuggestionErrorKey: output }; completion(output, [NSError errorWithDomain:ATZShellErrorDomain code:ATZShellTerminationStatusError userInfo:userInfo]); } }];