Table of Contents

RDC00212: Unrestored On Error Resume Next

Severity: Warning  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: UnrestoredOnErrorResumeNextAnalyzer

An On Error Resume Next has no On Error GoTo 0 or On Error GoTo <label> after it in its procedure.

After On Error Resume Next, a statement that raises an error is gone past, and the error is left in Err (RD-VBAL §5.4.4.1 On Error Statement). With neither after it, that holds for the rest of the procedure: a bug that raises an error there goes unseen, and the caller is never told.

An On Error GoTo 0 after the statements that may fail turns error handling off again, and an On Error GoTo <label> hands errors to a handler. An On Error GoTo -1 clears the current error and leaves Resume Next in force, so the finding stays. The statements are read in the order they are written, in any block of the procedure.

The finding is the On Error Resume Next statement.

How it is raised

Situation Example Resolution
An On Error Resume Next that no On Error GoTo follows. Sub DoSomething()
On Error Resume Next
' ...
End Sub
Write On Error GoTo 0 after the statements that may fail.

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca