Skip to content

Commit

Permalink
fix: Show error page if server is not running (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Nov 7, 2018
1 parent c954fe3 commit 6a2e07e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/ios/CDVWKWebViewEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,20 @@ - (id)loadRequest:(NSURLRequest *)request
}
request = [NSURLRequest requestWithURL:url];
}
return [(WKWebView*)_engineWebView loadRequest:request];
if ([self.webServer isRunning]) {
return [(WKWebView*)_engineWebView loadRequest:request];
} else {
NSString* errorHtml = [NSString stringWithFormat:
@"<html>"
@"<head><title>Error</title></head>"
@" <div style='font-size:2em'>"
@" <p>The App Server is not running.</p>"
@" <p>Close other apps and try again.</p>"
@" </div>"
@"</html>"
];
return [self loadHTMLString:errorHtml baseURL:request.URL];
}
}

- (id)loadHTMLString:(NSString *)string baseURL:(NSURL*)baseURL
Expand Down

0 comments on commit 6a2e07e

Please sign in to comment.