Error handler terminology
An
error handler is neither a
sub nor a function, rather, its a section of a sub or function that starts with a
label.
When an enabled error handler is handling an error, the error handler is said to be active.
Error handling policy of a sub or function
The policy that is in effect when a runtime error occurs specifies how that error is handled.
VBA has five policies:
Default | Stop current procedure and return the error object (err ) to the calling procedure and proceed according to calling procedure's error policy. |
Resume next | Execute «next» statement (that is the statement that also would have executed if no error had occurred) |
Goto | Set current procedure's policy to default and continue at the label that is associated with on error goto . |
Retry | |
Ignore | |
Terminate | Behaviour is implementation defined |
A sub's or function's error handling policy is changed with the
on error
statement.
When a function or sub is called, its policy is the Default policy, except if the sub/function is invoked from a host application, in which case it is set to Terminate.