| Page 1 of 1 | [ 2 posts ] |
|
Hi all,
I am currently wrapping some legacy JS code in YUI.use blocks and modulasing the old script files so they can interact with new YUI code. What I have noticed is when inline code ever errors within a YUI.use block all inline script below it is never executed. e.g.g I have a use block where an objects property is undefined, usually the page continues and inline scripts below are executed, however once in the use block when an error is hit code below is never run. Is there a reason for this, I'm keen to understand why this is the case? Thanks in advance |
|
When an exception is raised in javascript, it halts everything in the current execution stack. This means that any errors that are raised will prevent the execution of code further down the script block, if it resides in the same stack. This doesn't halt all script execution, just script execution within the same call stack.
I'm not directly familiar with inline javascript and error handling, but I would suspect that it has fairly liberal error handling, since one of JS's early principles was to suck up minor syntax errors and keep going (hence our legacy of horrible semicolon insertion rules). While it may not be practical in 100% of cases, I recommend refactoring your code to be more defensive, which should avoid errors like that. Alternatively, you could wrap everything in a try/catch block and ignore the exceptions that it throws. |
| Page 1 of 1 | [ 2 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group