Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve loadscript #55

Open
davidbau opened this issue Apr 3, 2014 · 6 comments
Open

Improve loadscript #55

davidbau opened this issue Apr 3, 2014 · 6 comments

Comments

@davidbau
Copy link
Member

davidbau commented Apr 3, 2014

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.

@weihang7
Copy link
Contributor

What do you mean by 'the URL is correct'?

@davidbau
Copy link
Member Author

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"

@weihang7
Copy link
Contributor

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) {
}

@davidbau
Copy link
Member Author

How odd! What sort of error can't be caught by try/catch?

On Wed, May 21, 2014 at 4:08 PM, Weihang Fan [email protected]:

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//issues/55#issuecomment-43807371
.

@weihang7
Copy link
Contributor

I also tried to just throw an error in the try clause, which worked correctly, being caught.

@weihang7
Copy link
Contributor

Oops, CoffeeScript.load does an ajax request. I'll patch in pencil-coffee-script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants