Added error handling messages

This commit is contained in:
Grant Limberg
2016-09-01 19:02:27 -07:00
parent c2a01f6db4
commit 94263ffcc1
6 changed files with 183 additions and 17 deletions

View File

@@ -11,6 +11,9 @@
#import "ServiceCom.h"
#import "NodeStatus.h"
@import AppKit;
NSString * const NetworkUpdateKey = @"com.zerotier.one.network-list";
NSString * const StatusUpdateKey = @"com.zerotier.one.status";
@@ -85,9 +88,22 @@ NSString * const StatusUpdateKey = @"com.zerotier.one.status";
} error:&error];
if(error) {
// TODO: Display error message
[self stop];
NSAlert *alert = [NSAlert alertWithError:error];
alert.alertStyle = NSCriticalAlertStyle;
[alert addButtonWithTitle:@"Quit"];
[alert addButtonWithTitle:@"Retry"];
NSModalResponse res = [alert runModal];
if(res == NSAlertFirstButtonReturn) {
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];
}
else if(res == NSAlertSecondButtonReturn) {
[self start];
return;
}
}
[[ServiceCom sharedInstance] getNodeStatus:^(NodeStatus *status) {
@@ -101,9 +117,22 @@ NSString * const StatusUpdateKey = @"com.zerotier.one.status";
} error:&error];
if (error) {
// TODO: Display error message
[self stop];
NSAlert *alert = [NSAlert alertWithError:error];
alert.alertStyle = NSCriticalAlertStyle;
[alert addButtonWithTitle:@"Quit"];
[alert addButtonWithTitle:@"Retry"];
NSModalResponse res = [alert runModal];
if(res == NSAlertFirstButtonReturn) {
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];
}
else if(res == NSAlertSecondButtonReturn) {
[self start];
return;
}
}
}