Visual Basic On Error Resume Next behavior inside async methods
0 reputation · 22 May 2023, 22:56 UTC
Problem Statement
In VB.NET, On Error Resume Next is often used to bypass runtime errors, but its interaction with asynchronous programming constructs is not well documented. When an Async method throws an exception, the language spec does not clearly state whether On Error Resume Next will swallow that exception, propagate it, or alter the stack trace.
Goal and Constraints
Determine how On Error Resume Next behaves when applied to code that calls an Async method which may throw, and whether this behavior is consistent across different .NET runtimes and Visual Studio versions. Additionally, assess whether compile‑time errors (e.g., undeclared variables) are still reported under On Error Resume Next when Option Explicit is enabled.
Unresolved Questions
- Does
On Error Resume Nextsuppress exceptions thrown inside anAsyncmethod, allowing the caller to continue execution? - If an exception is swallowed, is the original exception object lost, or can it be retrieved from the task’s
Exceptionproperty? - When
Option Explicitis on, doesOn Error Resume Nextstill produce compile‑time errors for undeclared identifiers within async methods?