mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Show an error when WebKit fails to load the requested resource
WebKit will e.g. fail to load resources identified as application/octet-stream.
This commit is contained in:
@@ -85,12 +85,14 @@ extern NSString* const kCommandRunnerURLScheme; // from HTMLOutput.h
|
||||
{
|
||||
self.runningCommand = NO;
|
||||
self.autoScrollHelper = nil;
|
||||
[super webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView*)sender didFailLoadWithError:(NSError*)error forFrame:(WebFrame*)frame
|
||||
{
|
||||
self.runningCommand = NO;
|
||||
self.autoScrollHelper = nil;
|
||||
[super webView:sender didFailLoadWithError:error forFrame:frame];
|
||||
}
|
||||
|
||||
// =========================================
|
||||
|
||||
@@ -4,6 +4,18 @@
|
||||
#import <OakAppKit/OakUIConstructionFunctions.h>
|
||||
#import <OakAppKit/NSColor Additions.h>
|
||||
|
||||
static NSString* EscapeHTML (NSString* str)
|
||||
{
|
||||
return [[[str stringByReplacingOccurrencesOfString:@"&" withString:@"&"] stringByReplacingOccurrencesOfString:@"<" withString:@"<"] stringByReplacingOccurrencesOfString:@"\"" withString:@"""];
|
||||
}
|
||||
|
||||
static void ShowLoadErrorForURL (WebFrame* frame, NSURL* url, NSError* error)
|
||||
{
|
||||
NSString* options = [[url scheme] isEqualToString:@"file"] ? @" -R" : @"";
|
||||
NSString* errorMsg = [NSString stringWithFormat:@"<title>Load Error</title><h1>Load Error</h1><p>WebKit reported <em>%@</em> while loading <tt><a href=\"#\" onClick=\"javascript:TextMate.system('/usr/bin/open%@ "%@"', null)\">%@</a></tt>.</p>", EscapeHTML([error localizedDescription]), options, EscapeHTML([url absoluteString]), EscapeHTML([url absoluteString])];
|
||||
[frame loadHTMLString:errorMsg baseURL:[NSURL fileURLWithPath:NSTemporaryDirectory()]];
|
||||
}
|
||||
|
||||
@interface HOBrowserView ()
|
||||
@property (nonatomic, readwrite) WebView* webView;
|
||||
@property (nonatomic, readwrite) HOStatusBar* statusBar;
|
||||
@@ -143,6 +155,18 @@
|
||||
[self setUpdatesProgress:YES];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView*)sender didFailProvisionalLoadWithError:(NSError*)error forFrame:(WebFrame*)frame
|
||||
{
|
||||
ShowLoadErrorForURL(frame, [[[frame provisionalDataSource] request] URL], error);
|
||||
[self webView:sender didFinishLoadForFrame:frame];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView*)sender didFailLoadWithError:(NSError*)error forFrame:(WebFrame*)frame
|
||||
{
|
||||
ShowLoadErrorForURL(frame, [[[frame provisionalDataSource] request] URL], error);
|
||||
[self webView:sender didFinishLoadForFrame:frame];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView*)sender didFinishLoadForFrame:(WebFrame*)frame
|
||||
{
|
||||
_statusBar.canGoBack = _webView.canGoBack;
|
||||
|
||||
Reference in New Issue
Block a user