Exceptions: Difference between revisions

Content added Content deleted
(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: Line 120:
//This code is always executed after exiting the try block
//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]]==
==[[Perl]]==