Skip to content

Commit

Permalink
Ignore failure in non-irccloud network requests, since that isn't a f…
Browse files Browse the repository at this point in the history
…ailure of the entire app.
  • Loading branch information
bemjb committed Sep 26, 2014
1 parent 53a2b38 commit 1de1637
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions AppDelegate.m
Expand Up @@ -116,7 +116,13 @@ - (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window
}
}

- (void)handleNetworkErrorForWebView:(WebView *)view {
- (void)handleNetworkError:(NSError *)error forWebView:(WebView *)view {
NSString *failingURL = [error.userInfo valueForKey:@"NSErrorFailingURLStringKey"];
if (!failingURL || [failingURL rangeOfString:url options:NSAnchoredSearch].location == NSNotFound) {
// If the URL isn't an irccloud URL, we don't care if it is down, the irccloud interface should still work.
return;
}

NSAlert *alert = [NSAlert alertWithMessageText:@"Unable to connect to IRCCloud" defaultButton:@"Retry" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:@"Check your internet connection."];
[alert beginSheetModalForWindow:window completionHandler:^(NSModalResponse responseCode) {
if (responseCode == NSModalResponseOK) {
Expand All @@ -128,11 +134,11 @@ - (void)handleNetworkErrorForWebView:(WebView *)view {
}

- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
[self handleNetworkErrorForWebView:sender];
[self handleNetworkError:error forWebView:sender];
}

- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
[self handleNetworkErrorForWebView:sender];
[self handleNetworkError:error forWebView:sender];
}

#pragma mark WebPolicyDelegate
Expand Down

0 comments on commit 1de1637

Please sign in to comment.