(commented out but potentially useful) methods to tap Java release
[jalview.git] / src / jalview / urls / IdentifiersUrlProvider.java
index c938666..f32e590 100644 (file)
@@ -76,14 +76,14 @@ public class IdentifiersUrlProvider extends UrlProviderImpl
    *          name of identifiers.org download file
    * @return hashmap of identifiers.org data, keyed by MIRIAM id
    */
-  private HashMap<String, UrlLink> readIdentifiers(
-          String idFileName)
+  private HashMap<String, UrlLink> readIdentifiers(String idFileName)
   {
     JSONParser parser = new JSONParser();
 
     // identifiers.org data
     HashMap<String, UrlLink> idData = new HashMap<String, UrlLink>();
 
+    String errorMessage = null;
     try
     {
       FileReader reader = new FileReader(idFileName);
@@ -99,8 +99,8 @@ public class IdentifiersUrlProvider extends UrlProviderImpl
       }
       else
       {
-        System.out
-                .println("Unexpected key returned from identifiers jalview service");
+        System.out.println(
+                "Unexpected key returned from identifiers jalview service");
         return idData;
       }
 
@@ -117,19 +117,19 @@ public class IdentifiersUrlProvider extends UrlProviderImpl
                 (String) item.get("prefix"));
         idData.put((String) item.get("id"), link);
       }
-    } catch (FileNotFoundException e)
+    } catch (IOException | ParseException e)
     {
-      e.printStackTrace();
-      idData.clear();
-    } catch (IOException e)
-    {
-      e.printStackTrace();
-      idData.clear();
-    } catch (ParseException e)
-    {
-      e.printStackTrace();
+      // unnecessary e.printStackTrace();
+      // Note how in JavaScript we can grab the first bytes from any file reader. 
+      // Typical report here is "NetworkError" because the file does not exist.
+      // "https://." is coming from System.getProperty("user.home"), but this could
+      // be set by the page developer to anything, of course.
+      errorMessage = (/** @j2sNative String.fromCharCode.apply(null, reader.$in.is.buf.slice(0,12)) || */e.toString());
       idData.clear();
     }
+    // BH 2018 -- added more valuable report
+    if (errorMessage != null)
+      System.err.println("IdentifiersUrlProvider: cannot read " + idFileName + ": " + errorMessage);
     return idData;
   }