Try, Throw, Catch, Finally

Error handling in Javascript.

The Try statement will let you handle any errors that the code in the Try block may have caused. Try needs to be followed by either catch or finally or both.


Catch statement is invoked after an error occurs. No error, so no catch. Throw a custom error to catch.


Finally is invoked whether or not there's an error.

Finally with en error. Finally without an error. Finally without a catch.