Results 1 to 5 of 5

Is this a good way to handle error?

Threaded View

david90 Is this a good way to handle... 02-25-2013, 07:26 PM
Norie Re: Is this a good way to... 02-25-2013, 07:30 PM
david90 Re: Is this a good way to... 02-25-2013, 07:47 PM
Norie Re: Is this a good way to... 02-25-2013, 07:49 PM
shg Re: Is this a good way to... 02-25-2013, 08:08 PM
  1. #1
    Registered User
    Join Date
    09-19-2011
    Location
    oc,ca
    MS-Off Ver
    Excel 2003
    Posts
    44

    Is this a good way to handle error?

    Private Function F1() As String
    
        On Error GoTo errHandler
        
        Open "c:\pfms.txt" For Input As #1
    
    exitHere:
        
        Exit Function
        
    errHandler:
        MsgBox "Error " & Err.Number
        Select Case Err
        
            Case 53 ' unrecoverable error
                Err.Raise 1, "F1"
                Exit Function
                
        End Select
        
    End Function
    I have a function called F1 and it has an error handler that handles err 53 (file not found err). When err 53 occurs, the error handler raises an an err 1 to exit the function. The function that calls F1 also has an error handler and the error handler reacts to the err 1 raised by the function F1.

    Is it a good programming practice to notify the function caller that an error has occurred in the called function by using the err.raise method?
    Last edited by david90; 02-25-2013 at 07:32 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1