Re: Error Handling Etiquette

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Marina (someone_at_nospam.com)
Date: 09/08/04


Date: Wed, 8 Sep 2004 12:49:32 -0400

Move the 'final statements' to inside the try block. That way the stuff at
106, is right after the try/catch/finally, and should always be executed
anyway.

"mark" <mark@discussions.microsoft.com> wrote in message
news:82997FA6-E71B-478D-A764-FB077924ED14@microsoft.com...
> Consider the following error handling scheme:
>
> Statements
> Try
> more stastements
> Catch ex As Exception
> MsgBox(ex.Message)
> GoTo 106
> End Try
> final statements
> 106: 'some meaningless comment
> End Sub
>
> I want to abort the sub and not execute the final statements if an error
> occurs.
> I use the GoTo 106 to branch to the last line which is a comment.
>
> It works, but it seems sloppy to me. How would a good programmer abort the
> sub in an error condition?
> --
> mark



Relevant Pages

  • Re: Access module does not continue past the Filter Method
    ... Execute the procedure, and single-step through it with F8 so you can trace ... Public Sub Apply_Tech_Filter ... Debug.Print "Past the Filter" ... Debug.Print "Before the Append Statement" ...
    (microsoft.public.access.modulesdaovba)
  • Re: Error:Invalid procedure call or argument
    ... > Number 0 everytiime I execute this code: ... > Private Sub Update() ... > On Error GoTo ErrHand ... > Following is an example of the completed SQL string. ...
    (microsoft.public.access.formscoding)
  • Re: Using ADO.NET to prcoess T-SQL batches
    ... The way cool additional thing Whidbey ADO.NET v2 provides for this is the ... > only execute batches under a certain size, either 40K or 80K, if I ... >> Print statements return their data to an ADO.NET client as InfoMessages. ... Private Sub Button1_Click(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Code wont execute Main Macro Calls - non breaking spaces
    ... Public Sub MainMacro() ... Sub DoFindReplace(FindText As String, ReplaceText As String, ... My MAIN MACRO does not execute the first 2 options DO FIND AND REPLACE. ...
    (microsoft.public.word.vba.general)
  • Re: Code wont execute Main Macro Calls - non breaking spaces
    ... Public Sub MainMacro() ... Sub DoFindReplace(FindText As String, ReplaceText As String, ... My MAIN MACRO does not execute the first 2 options DO FIND AND REPLACE. ...
    (microsoft.public.word.vba.general)