we can Handle Erors in 2 ways by using
1. Triggered Events.
2. Recovery steps.
3. Post Recovery Test-Run.
At Script Level you can use the On Error Resume Next statement.
Following code throws an Exception at Line 6, and the execution cannot proceed further.
msgbox "hello"
call funcOne
msgbox "after function call"
function funcOne()
msgbox 1/0
end function
Here the output is "hello", the script never reaches to the second output statement
To proceed further after the exception occured, use "On Error Resume Next" statement, which just ignores the Exception and proceeds.
msgbox "hello"
call funcOne
msgbox "after function call"
function funcOne()
On Error Resume Next
msgbox 1/0
end function
Here the output contains both the messages
To customize the error message displayed, use the Err Object
msgbox "hello"
call funcOne
msgbox "after function call"
function funcOne()
On Error Resume Next
msgbox 1/0
msgbox "Error Message: "&Err.Description&" and Error code: "&Err.Number
end function
Here the output is 3 msgs, including the Error description.
You can also clear the Error object using Err.clear().
- Recovery Scenarios.
- Using “On Error” statement
1. Triggered Events.
2. Recovery steps.
3. Post Recovery Test-Run.
At Script Level you can use the On Error Resume Next statement.
Following code throws an Exception at Line 6, and the execution cannot proceed further.
msgbox "hello"
call funcOne
msgbox "after function call"
function funcOne()
msgbox 1/0
end function
Here the output is "hello", the script never reaches to the second output statement
To proceed further after the exception occured, use "On Error Resume Next" statement, which just ignores the Exception and proceeds.
msgbox "hello"
call funcOne
msgbox "after function call"
function funcOne()
On Error Resume Next
msgbox 1/0
end function
Here the output contains both the messages
To customize the error message displayed, use the Err Object
msgbox "hello"
call funcOne
msgbox "after function call"
function funcOne()
On Error Resume Next
msgbox 1/0
msgbox "Error Message: "&Err.Description&" and Error code: "&Err.Number
end function
Here the output is 3 msgs, including the Error description.
You can also clear the Error object using Err.clear().