I believe that is the correct behavior. It's just that in the case of the
JavaScript version of the applet you get an HTML error message, and in Java
you get a Java error message. Your code is just printing that error message
(fileData).

But I see. you were expecting load("xxxx") to throw an error instead. That
does make sense to me. But, if you think about it, there's no way for the
applet to know what the HTML will be that defines a "file not found" error.
These messages vary a lot. It is tested when you actually *load *the file,
because we know in that case what the options are, and those error messages
are not of them.

But with load("xxxx") the file to load could be anything, including a file
that reports exactly that HTML. So it never throws an error, and you just
have to check to make sure yourself that you have the data you expect.


Bob


On Mon, Feb 29, 2016 at 11:53 AM, Rolf Huehne <rolf.hue...@leibniz-fli.de>
wrote:

> Hi Bob,
>
> 'try / catch' doesn't seem to work in Jmol 14.4.3_2016.02.17
> (application and applet at
> http://chemapps.stolaf.edu/jmol/jsmol/jsmol.htm) if it is used to check
> loading a text file using the 'load' function.
>
> ---- Example code ------------
> function loadTest(fileName) {
>    var fileData = [];
>    while(true) {
>       try {
>         fileData = load(fileName);
>       } catch(e) {
>         print e;
>         print "ERROR: could not load file '" + fileName + "'";
>         return fileData;
>       }
>       print "NOTE: loaded file '" + fileName + "' succesfully";
>       break;
>    }
>    return fileData;
> }
>
> x=loadTest("wrongFilename.txt");
> print x;
>
> --- Output from application -----------
> NOTE: loaded file 'wrongFilename.txt' succesfully
> java.io.FileNotFoundException: wrongFilename.txt (No such file or
> directory)
>
> --- Output from applet  ---------------
> NOTE: loaded file 'wrongFilename.txt' succesfully
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <html><head>
> <title>404 Not Found</title>
> </head><body>
> <h1>Not Found</h1>
> <p>The requested URL /jmol/jsmol/wrongFilename.txt was not found on this
> server.</p>
> <hr>
> <address>Apache Server at chemapps.stolaf.edu Port 80</address>
> </body></html>
> ---------------------------------------
>
> Regards,
> Rolf
>
> --
>
> Rolf Huehne
> Postdoc
>
> Leibniz Institute on Aging - Fritz Lipmann Institute (FLI)
> Beutenbergstrasse 11
> 07745 Jena, Germany
>
> Phone:   +49 3641 65 6205
> Fax:     +49 3641 65 6210
> E-Mail:  rolf.hue...@leibniz-fli.de
> Website: http://www.leibniz-fli.de
>
>            Scientific Director: Prof. Dr. K. Lenhard Rudolph
>         Head of Administration: Dr. Daniele Barthel
> Chairman of Board of Trustees: Burkhard Zinner
>
> VAT No: DE 153 925 464
> Register of Associations: No. 230296, Amtsgericht Jena
> Tax Number: 162/141/08228
>
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>



-- 
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to