The try...catch...finally
statement provides a way to handle some or all of the errors that may
occur in a given block of code, while still running code. If errors
occur that are not handled, JavaScript provides the normal error
message.
The try block contains code that may provoke an error, while the catch block contains the code that handles some or all errors. If an error occurs in the try block, program control is passed to the catch block. The value of exception is the value of the error that occurred in the try block. If no error occurs, the code in the catch block is never executed.
You can pass the error up to the next level by using the throw statement to re-throw the error.
After all the statements in the try block have been executed and error handling has been done in the catch block, the statements in the finally block are executed, whether or not an error was handled. The code in the finally block is guaranteed to run unless an unhandled error occurs (for example, a run-time error inside the catch block).