How to raise an exception in VB.NET

vb.netException

vb.net Problem Overview


How should an exception be raised in VB.NET?

vb.net Solutions


Solution 1 - vb.net

You would throw a new exception.

Have a look at Throw Statement (Visual Basic)

> The Throw statement throws an exception that you can handle with > structured exception-handling code (Try...Catch...Finally) or > unstructured exception-handling code (On Error GoTo). You can use the > Throw statement to trap errors within your code because Visual Basic > moves up the call stack until it finds the appropriate > exception-handling code.

EDIT

By request and from the link

Throw New System.Exception("An exception has occurred.")

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCJ7View Question on Stackoverflow
Solution 1 - vb.netAdriaan StanderView Answer on Stackoverflow