Inspection Details

UnhandledOnErrorResumeNext


Summary
Finds instances of 'On Error Resume Next' that don't have a corresponding 'On Error GoTo 0' to restore error handling.
Reasoning
'On Error Resume Next' should be constrained to a limited number of instructions, otherwise it supresses error handling for the rest of the procedure; 'On Error GoTo 0' reinstates error handling. This inspection helps treating 'Resume Next' and 'GoTo 0' as a code block (similar to 'With...End With'), essentially.
The following code example(s) would trigger this inspection:

Public Sub DoSomething()
    On Error Resume Next ' error handling is never restored in this scope.
    ' ...
End Sub

The following code example(s) would not trigger this inspection:

Public Sub DoSomething()
    On Error Resume Next
    ' ...
    On Error GoTo 0
End Sub


Back to List