Revision: 21968
          http://sourceforge.net/p/bibdesk/svn/21968
Author:   hofman
Date:     2018-02-19 21:54:02 +0000 (Mon, 19 Feb 2018)
Log Message:
-----------
simplify getting error in jester web parser

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

Modified: trunk/bibdesk/BDSKJSTORWebParser.m
===================================================================
--- trunk/bibdesk/BDSKJSTORWebParser.m  2018-02-19 21:50:10 UTC (rev 21967)
+++ trunk/bibdesk/BDSKJSTORWebParser.m  2018-02-19 21:54:02 UTC (rev 21968)
@@ -91,25 +91,16 @@
 }
 
 - (void)downloadDidFinish:(BDSKCitationDownload *)download  {
-    NSError *error = nil;
+    NSError *error = [download error];
     NSArray *bibtexItems = nil;
 
     if ([download failed]) {
-        
-        error = [download error];
-        
-    } else {
-        
         NSString *bibtexData = [download string];
         
         // remove characters before the first @ symbol
         NSRange range = [bibtexData rangeOfString:@"@"];
-        if (range.location == NSNotFound) {
-            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];
-        } else {
+        if (range.location != NSNotFound) {
             bibtexData = [bibtexData substringFromIndex:range.location];
-            
             // parse BibTeX data
             if ([BDSKBibTeXParser canParseString:bibtexData])
                 bibtexItems = [BDSKBibTeXParser itemsFromString:bibtexData 
owner:nil error:&error];
@@ -116,6 +107,11 @@
         }
     }
     
+    if ([bibtexItems count] == 0 && 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 didFinishDownload:download findingItems:bibtexItems 
withSuccess:[bibtexItems count] > 0 error:error];
 }
 

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