aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPBundleHTMLOutputController.h2
-rw-r--r--Source/SPBundleHTMLOutputController.m22
2 files changed, 24 insertions, 0 deletions
diff --git a/Source/SPBundleHTMLOutputController.h b/Source/SPBundleHTMLOutputController.h
index ea0b96da..3665fc8e 100644
--- a/Source/SPBundleHTMLOutputController.h
+++ b/Source/SPBundleHTMLOutputController.h
@@ -33,6 +33,7 @@
NSString *initHTMLSourceString;
NSString *windowUUID;
NSString *docUUID;
+ BOOL suppressExceptionAlert;
WebPreferences *webPreferences;
}
@@ -41,6 +42,7 @@
@property(readwrite,retain) NSString *initHTMLSourceString;
@property(readwrite,retain) NSString *windowUUID;
@property(readwrite,retain) NSString *docUUID;
+@property(assign) BOOL suppressExceptionAlert;
- (IBAction)printDocument:(id)sender;
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index 12af6bcf..3c47964a 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -33,6 +33,7 @@
@synthesize initHTMLSourceString;
@synthesize windowUUID;
@synthesize docUUID;
+@synthesize suppressExceptionAlert;
/**
* Initialisation
@@ -50,6 +51,7 @@
[webView setEditable:NO];
[webView setShouldCloseWithWindow:YES];
[webView setShouldUpdateWhileOffscreen:NO];
+ suppressExceptionAlert = NO;
}
@@ -374,6 +376,8 @@
return @"makeHTMLOutputWindowKeyWindow";
if (aSelector == @selector(closeHTMLOutputWindow))
return @"closeHTMLOutputWindow";
+ if (aSelector == @selector(suppressExceptionAlert))
+ return @"suppressExceptionAlert";
return @"";
}
@@ -399,6 +403,9 @@
if (selector == @selector(closeHTMLOutputWindow)) {
return NO;
}
+ if (selector == @selector(suppressExceptionAlert)) {
+ return NO;
+ }
return YES;
}
@@ -440,8 +447,14 @@
- (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]];
+ if([self suppressExceptionAlert]) {
+ NSLog(@"%@", mes);
+ return;
+ }
+
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"JavaScript Exception", @"javascript exception")
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
@@ -525,6 +538,15 @@
}
/**
+ * JavaScript window.system.suppressExceptionAlert() function
+ * to suppress an exception alert, instead write the message to NSLog
+ */
+- (void)suppressExceptionAlert
+{
+ [self setSuppressExceptionAlert:YES];
+}
+
+/**
* JavaScript window.system.run('a_command'|new Array('a_command', 'uuid')) function
* to return the result of the BASH command a_command
*/