Open davidbau opened 10 years ago
What do you mean by 'the URL is correct'?
E.g., when the URL is misspelled and doesn't load, or when it loads gibberish that cannot be interpreted as javascript, it just says something like "Script error". Ideally it should highlight the loadscript line and print an error message "Could not load script http://badurl"
I tried to use try...catch, but the following code fails to catch the error, which is thrown in CoffeeScript.load, and lets the error pass through:
try {
CoffeeScript.load(url, callback);
} catch (err) {
}
How odd! What sort of error can't be caught by try/catch?
On Wed, May 21, 2014 at 4:08 PM, Weihang Fan notifications@github.comwrote:
I tried to use try...catch, but the following code fails to catch the error, which is thrown in CoffeeScript.load, and lets the error pass through:
try { CoffeeScript.load(url, callback); } catch (err) { }
— Reply to this email directly or view it on GitHubhttps://github.com/PencilCode/jquery-turtle/issues/55#issuecomment-43807371 .
I also tried to just throw an error in the try clause, which worked correctly, being caught.
Oops, CoffeeScript.load does an ajax request. I'll patch in pencil-coffee-script.
We're going to start using loadscript in material. For example, an exercise about search algorithms will begin with this:
await loadscript '//csp.pencilcode.net/lib/find.coffee', defer()
A couple things should be fixed: (1) Let's shorten this line by shortening the name of the function to 'script' from 'loadscript'. (2) When the URL is incorrect, the error message shown is incomprehensible. There should be a good error message, and it should highlight the line of code that contains the call to load the script.