Jump to content

Exceptions: Difference between revisions

added JavaScript
(This task was getting no love, squirreled away in the Language Features category. Moved back to the Programming Tasks section until most of the tasks get a better categorization system.)
(added JavaScript)
Line 120:
//This code is always executed after exiting the try block
}
 
==[[JavaScript]]==
[[Category:JavaScript]]
 
===Throwing exceptions===
 
function doStuff() {
throw new Error('Not implemented!');
}
 
===Catching exceptions===
 
try {
element.attachEvent('onclick', doStuff);
}
catch(e if e instanceof TypeError) {
element.addEventListener('click', doStuff, false);
}
finally {
eventSetup = true;
}
 
==[[Perl]]==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.