Revision: 29597
          http://sourceforge.net/p/bibdesk/svn/29597
Author:   hofman
Date:     2025-09-17 16:05:35 +0000 (Wed, 17 Sep 2025)
Log Message:
-----------
load error in webview when policy cannot be created

Modified Paths:
--------------
    trunk/bibdesk/BDSKWebView.m

Modified: trunk/bibdesk/BDSKWebView.m
===================================================================
--- trunk/bibdesk/BDSKWebView.m 2025-09-17 14:31:21 UTC (rev 29596)
+++ trunk/bibdesk/BDSKWebView.m 2025-09-17 16:05:35 UTC (rev 29597)
@@ -479,7 +479,7 @@
         [delegate webView:sender didFinishLoadForFrame:frame];
 }
 
-- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error 
forFrame:(WebFrame *)frame{
+- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error 
forFrame:(WebFrame *)frame {
     if ([delegate respondsToSelector:@selector(webView:didFailLoadForFrame:)])
         [delegate webView:sender didFailLoadForFrame:frame];
     [self webView:sender setLoading:[sender isLoading]];
@@ -491,7 +491,7 @@
         
         // "plug-in handled load" is reported as a failure with code 204
         if ([[error domain] isEqualToString:WebKitErrorDomain] == NO || [error 
code] != 204) {
-            NSURL *url = [[[frame provisionalDataSource] request] URL];
+            NSURL *url = [[([frame provisionalDataSource] ?: [frame 
dataSource]) request] URL];
             NSString *errorHTML = [NSString 
stringWithFormat:@"<html><head><title>%@</title></head><body><h1>%@</h1></body></html>",
 NSLocalizedString(@"Error", @"Placeholder web group label"), [error 
localizedDescription]];
             [frame loadAlternateHTMLString:errorHTML baseURL:url 
forUnreachableURL:url];
         }
@@ -532,6 +532,18 @@
         [listener download];
 }
 
+- (void)webView:(WebView *)webView unableToImplementPolicyWithError:(NSError 
*)error frame:(WebFrame *)frame {
+    if (([[error domain] isEqualToString:NSURLErrorDomain] == NO || [error 
code] != NSURLErrorCancelled) ||
+        ([[error domain] isEqualToString:WebKitErrorDomain] == NO || [error 
code] != 204)) {
+        // !!! logs are here to help diagnose problems that users are reporting
+        NSLog(@"-[%@ %@] %@", [self class], NSStringFromSelector(_cmd), error);
+        
+        NSURL *url = [[[frame provisionalDataSource] request] URL];
+        NSString *errorHTML = [NSString 
stringWithFormat:@"<html><head><title>%@</title></head><body><h1>%@</h1></body></html>",
 NSLocalizedString(@"Error", @"Placeholder web group label"), [error 
localizedDescription]];
+        [frame loadAlternateHTMLString:errorHTML baseURL:url 
forUnreachableURL:url];
+    }
+}
+
 #pragma mark WebUIDelegate protocol
 
 - (void)webView:(WebView *)sender setStatusText:(NSString *)text {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to