try {
// Code to be executed
} catch (error) {
// Code to execute there is an error
} finally {
// Optional – always execute this code
}
|
|
As a best practice, use try..catch whenever possible.
|