diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPBundleHTMLOutputController.m | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m index 8a5b66e6..7cad079b 100644 --- a/Source/SPBundleHTMLOutputController.m +++ b/Source/SPBundleHTMLOutputController.m @@ -25,6 +25,8 @@ #import "SPBundleHTMLOutputController.h" #import "SPAlertSheets.h" +@class WebScriptCallFrame; + @implementation SPBundleHTMLOutputController @synthesize docTitle; @@ -300,6 +302,20 @@ } } +- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame +{ + if(error) { + NSLog(@"%@", [error localizedDescription]); + } +} + +- (void)webView:(WebView *)webView didFailLoadWithError:(NSError*)error forFrame:(WebFrame *)frame +{ + if(error) { + NSLog(@"%@", [error localizedDescription]); + } +} + #pragma mark - #pragma mark JS support @@ -329,10 +345,11 @@ return NO; } -- (void)webView:(WebView *)sender windowScriptObjectAvailable: (WebScriptObject *)windowScriptObject +- (void)webView:(WebView *)sender windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject { [windowScriptObject setValue:self forKey:@"system"]; + [webView setScriptDebugDelegate:self]; } + (NSString *)webScriptNameForSelector:(SEL)aSelector @@ -372,10 +389,33 @@ return YES; } -- (void)windowScriptObjectAvailable:(WebScriptObject*)webScriptObject { - [webScriptObject setValue:self forKey:@"system"]; +- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source baseLineNumber:(NSUInteger)lineNumber fromURL:(NSURL *)url withError:(NSError *)error forWebFrame:(WebFrame *)webFrame +{ + NSString *mes = [NSString stringWithFormat:@"Failed to parse JavaScript source:\nline = %ld\nerror = %@ with\n%@\nfor source = \n%@", lineNumber, [error localizedDescription], [error userInfo], source]; + + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"JavaScript Parsing Error", @"javascript parsing error") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:mes]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; } +- (void)webView:(WebView *)webView exceptionWasRaised:(WebScriptCallFrame *)frame sourceId:(NSInteger)sid line:(NSInteger)lineno forWebFrame:(WebFrame *)webFrame +{ + NSString *mes = [NSString stringWithFormat:@"Exception:\nline = %ld\nfunction = %@\ncaller = %@\nexception = %@", lineno, [frame functionName], [frame caller], [frame userInfo], [frame exception]]; + + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"JavaScript Exception", @"javascript exception") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:mes]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; +} /** * JavaScript window.system.getShellEnvironmentForName('a_key') function to * return the value for key keyName |