The try statement is used to define the code block to run i.e, to try.
The catch statement is used to define a code block to handle any error.
The finally statement is used to define a code block to run regardless of the result.
The throw statement is used to define a custom error.
Its syntax is:-
// try_code - Code block to run
// catch_code - Code block to handle errors
// finally_code - Code block to be executed regardless of the try result
|try_code||Required. Code block to be tested while executing.|
|error||A local reference to the error object.|
|catch_code||Optional. Code block to execute if an error occurs.|
|finally_code||Optional. Code block to execute regardless of the try result|