JAL-3026 fixes ?j2strace=xxx message, user.home, error msg in
[jalview.git] / src / jalview / urls / IdentifiersUrlProvider.java
index 0988e7d..f32e590 100644 (file)
@@ -83,6 +83,7 @@ public class IdentifiersUrlProvider extends UrlProviderImpl
     // identifiers.org data
     HashMap<String, UrlLink> idData = new HashMap<String, UrlLink>();
 
+    String errorMessage = null;
     try
     {
       FileReader reader = new FileReader(idFileName);
@@ -116,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;
   }