diff --git a/PBGitWindowController.h b/PBGitWindowController.h index ae2298b..b262fed 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -31,6 +31,7 @@ - (void)useToolbar:(NSToolbar *)toolbar; - (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText; - (void)showErrorSheet:(NSError *)error; +- (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output; - (IBAction) showCommitView:(id)sender; - (IBAction) showHistoryView:(id)sender; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index aba1987..7e277e1 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -137,6 +137,18 @@ [[NSAlert alertWithError:error] beginSheetModalForWindow: [self window] modalDelegate:self didEndSelector:nil contextInfo:nil]; } +- (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output +{ + NSString *command = [arguments componentsJoinedByString:@" "]; + NSString *reason = [NSString stringWithFormat:@"%@\n\ncommand: git %@\n%@", message, command, output]; + NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys: + title, NSLocalizedDescriptionKey, + reason, NSLocalizedRecoverySuggestionErrorKey, + nil]; + NSError *error = [NSError errorWithDomain:PBGitRepositoryErrorDomain code:0 userInfo:userInfo]; + [self showErrorSheet:error]; +} + #pragma mark - #pragma mark Toolbar Delegates