+ Reply to Thread
Results 1 to 5 of 5

Is this a good way to handle error?

  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?

    Please Login or Register  to view this content.
    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.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Is this a good way to handle error?

    You could check for the file using Dir.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-19-2011
    Location
    oc,ca
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Is this a good way to handle error?

    @Norie,

    I know I should but this question not about file i/o. I was asking about how I handle the error. I purposely opene a file that does not exist to cause an error.
    Last edited by jeffreybrown; 02-25-2013 at 08:11 PM. Reason: Please do not quote entire posts. Just cause clutter.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Is this a good way to handle error?

    That answer wasn't about file I/O, it was to show a different way to handle the problem.
    Last edited by Norie; 02-25-2013 at 08:34 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Is this a good way to handle error?

    It's a way, and it's a good way if it makes your code easier to understand. Norie's point, and I agree, is that it's good practice to avoid errors when it's reasonable to do so.

    User-defined errors should start at 513 to avoid overlap with system errors (0 to 512)
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

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