Revision: 22013
          http://sourceforge.net/p/bibdesk/svn/22013
Author:   hofman
Date:     2018-02-22 16:00:08 +0000 (Thu, 22 Feb 2018)
Log Message:
-----------
Only return in one place from parser

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

Modified: trunk/bibdesk/BDSKArxivParser.m
===================================================================
--- trunk/bibdesk/BDSKArxivParser.m     2018-02-22 15:52:09 UTC (rev 22012)
+++ trunk/bibdesk/BDSKArxivParser.m     2018-02-22 16:00:08 UTC (rev 22013)
@@ -110,30 +110,20 @@
     AGRegex *journalRegex3 = [AGRegex 
regexWithPattern:@"(.+[^0-9])([0-9]+):(.*),([0-9]{4})"
                                                options:AGRegexMultiline];
     
-    NSError *error = nil;
+    NSError *searchError = nil;
             
     // fetch the arxiv search results
     NSArray *arxivSearchResults = nil;
     NSXMLElement *rootElement = [[self xmlDocument] rootElement];
     
-    arxivSearchResults = [rootElement nodesForXPath:arxivSearchResultNodePath 
error:&error];
+    arxivSearchResults = [rootElement nodesForXPath:arxivSearchResultNodePath 
error:&searchError];
     
-    // bail out with an XML error if the Xpath query fails
-    if (0 == [arxivSearchResults count]) {
-        if (error == nil) {
-            error = [NSError mutableLocalErrorWithCode:kBDSKWebParserFailed 
localizedDescription:NSLocalizedString(@"No search results found", @"Web parser 
error")];
-            [error setValue:NSLocalizedString(@"Unable to parse this page.  
Please report this to BibDesk's developers and provide the URL.", @"Web parser 
error") forKey:NSLocalizedRecoverySuggestionErrorKey];
-        }
-        [[self delegate] webParser:self didFinishWithSuccess:NO error:error];
-        return;
-    }
-    
     NSMutableArray *items = [NSMutableArray arrayWithCapacity:0];
 
     for (NSXMLNode *arxivSearchResult in arxivSearchResults) {
         
         // fetch the arxiv links
-        
+        NSError *error = nil;
         NSArray *arxivLinkNodes = [arxivSearchResult 
nodesForXPath:arxivLinkNodePath
                                                              error:&error];
         
@@ -286,14 +276,12 @@
         
     }
         
-    if (0 == [items count]) {
-        error = [NSError mutableLocalErrorWithCode:kBDSKWebParserFailed 
localizedDescription:NSLocalizedString(@"No search results found", @"Web parser 
error")];
-        [error setValue:NSLocalizedString(@"Unable to parse this page.  Please 
report this to BibDesk's developers and provide the URL.", @"Web parser error") 
forKey:NSLocalizedRecoverySuggestionErrorKey];
-        [[self delegate] webParser:self didFinishWithSuccess:NO error:error];
-        return;
+    if (0 == [items count] && searchError == nil) {
+        searchError = [NSError mutableLocalErrorWithCode:kBDSKWebParserFailed 
localizedDescription:NSLocalizedString(@"No search results found", @"Web parser 
error")];
+        [searchError setValue:NSLocalizedString(@"Unable to parse this page.  
Please report this to BibDesk's developers and provide the URL.", @"Web parser 
error") forKey:NSLocalizedRecoverySuggestionErrorKey];
     }
     
-    [self didFinishStartingFindingItems:items withSuccess:YES error:nil];
+    [self didFinishStartingFindingItems:items withSuccess:[items count] > 0 
error:searchError];
 }
 
 

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


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to