Skip to content
Browse files

GPGException.reason is potentially localized, so use it

  • Loading branch information...
1 parent 9741a98 commit bbe6121db0b4f8767a771cbc32a6e3229b19ba5b @idodeclare idodeclare committed Mar 13, 2012
Showing with 20 additions and 10 deletions.
  1. +20 −10 Source/GPGServices.m
View
30 Source/GPGServices.m
@@ -72,8 +72,15 @@ - (void)importKeyFromData:(NSData*)data {
NSString* importText = nil;
@try {
importText = [gpgc importFromData:data fullImport:NO];
+
+ if (gpgc.error)
+ @throw gpgc.error;
} @catch(GPGException* ex) {
- [self displayOperationFailedNotificationWithTitle:@"Import failed:"
+ [self displayOperationFailedNotificationWithTitle:[ex reason]
+ message:[ex description]];
+ return;
+ } @catch(NSException* ex) {
+ [self displayOperationFailedNotificationWithTitle:@"Import failed."
message:[ex description]];
return;
}
@@ -325,7 +332,7 @@ -(NSString *)encryptTextString:(NSString *)inputString
return [outputData gpgString];
} @catch(GPGException* localException) {
- [self displayOperationFailedNotificationWithTitle:@"Encryption failed."
+ [self displayOperationFailedNotificationWithTitle:[localException reason]
message:[localException description]];
return nil;
} @catch(NSException* localException) {
@@ -369,7 +376,7 @@ -(NSString *)decryptTextString:(NSString *)inputString
if (ctx.error)
@throw ctx.error;
} @catch (GPGException* localException) {
- [self displayOperationFailedNotificationWithTitle:@"Decryption failed."
+ [self displayOperationFailedNotificationWithTitle:[localException reason]
message:[localException description]];
return nil;
@@ -424,7 +431,7 @@ -(NSString *)signTextString:(NSString *)inputString
return [outputData gpgString];
} @catch(GPGException* localException) {
- [self displayOperationFailedNotificationWithTitle:@"Signing failed."
+ [self displayOperationFailedNotificationWithTitle:[localException reason]
message:[localException description]];
return nil;
} @catch(NSException* localException) {
@@ -633,8 +640,7 @@ - (NSString*)detachedSignFile:(NSString*)file withKeys:(NSArray*)keys {
} @catch (GPGException* e) {
if([GrowlApplicationBridge isGrowlRunning]) {//This is in a loop, so only display Growl...
NSString *msg = [NSString stringWithFormat:@"%@\n\n%@", [file lastPathComponent], e];
- [self displayOperationFailedNotificationWithTitle:@"Signing failed."
- message:msg];
+ [self displayOperationFailedNotificationWithTitle:[e reason] message:msg];
}
} @catch (NSException* e) {
if([GrowlApplicationBridge isGrowlRunning]) //This is in a loop, so only display Growl...
@@ -823,7 +829,7 @@ - (void)encryptFiles:(NSArray*)files {
@throw ctx.error;
} @catch(GPGException* localException) {
- [self displayOperationFailedNotificationWithTitle:@"Encryption failed."
+ [self displayOperationFailedNotificationWithTitle:[localException reason]
message:[localException description]];
return;
} @catch(NSException* localException) {
@@ -898,8 +904,7 @@ - (void)decryptFiles:(NSArray*)files {
} @catch(GPGException* ex) {
if(files.count == 1 || [GrowlApplicationBridge isGrowlRunning]) {//This is in a loop, so only display Growl...
NSString *msg = [NSString stringWithFormat:@"%@\n\n%@", [file lastPathComponent], ex];
- [self displayOperationFailedNotificationWithTitle:@"Decryption failed."
- message:msg];
+ [self displayOperationFailedNotificationWithTitle:[ex reason] message:msg];
}
} @catch (NSException* localException) {
/*
@@ -948,7 +953,7 @@ - (void)importKeyFromData:(NSData*)data {
@try {
importText = [ctx importFromData:data fullImport:NO];
} @catch(GPGException* ex) {
- [self displayOperationFailedNotificationWithTitle:@"Import failed:"
+ [self displayOperationFailedNotificationWithTitle:[ex reason]
message:[ex description]];
return;
}
@@ -1001,6 +1006,11 @@ - (void)importFiles:(NSArray*)files {
message:[file lastPathComponent]];
}
*/
+ } @catch(GPGException* ex) {
+ if(files.count == 1 || [GrowlApplicationBridge isGrowlRunning]) {//This is in a loop, so only display Growl...
+ NSString *msg = [NSString stringWithFormat:@"%@\n\n%@", [file lastPathComponent], ex];
+ [self displayOperationFailedNotificationWithTitle:[ex reason] message:msg];
+ }
} @catch(NSException* ex) {
if(files.count == 1 || [GrowlApplicationBridge isGrowlRunning]) {//This is in a loop, so only display Growl...
NSString *msg = [NSString stringWithFormat:@"%@\n\n%@", [file lastPathComponent], ex];

0 comments on commit bbe6121

Please sign in to comment.
Something went wrong with that request. Please try again.