Error Handling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pentahari
    New Member
    • Dec 2007
    • 60

    Error Handling

    How to give the Common Error statement to all procedure and function.

    For ex
    [PHP]
    Sub sub1()
    On Error Resume Next
    statement.....
    End Sub

    Sub sub2()
    On Error Resume Next
    statement.....
    End Sub[/PHP]
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    What is your question?

    I usually write a globally accessible function in my Module that handles all errors for all functions. However, in all functions I just have something like this:

    [code=vb]
    Public Function ReadTable(MyPar ameter) as Variant
    On Error GoTo Error_ReadTable
    'normal code

    Error_ReadTable :
    'error handling code
    'call a write function or format function
    'to display error or log error
    End Function
    [/code]

    I would be more specific but I don't know what your looking for.

    Comment

    • pentahari
      New Member
      • Dec 2007
      • 60

      #3
      How to give the Common Error statement to all procedures and functions.

      My old code is
      [PHP]
      Sub sub1()
      On Error Resume Next
      statement.....
      End Sub

      Sub sub2()
      On Error Resume Next
      statement.....
      End Sub[/PHP]

      I always use error statement with in all procedures and functions, but i want one error statement handle all procedure errors.

      Comment

      • Sick0Fant
        New Member
        • Feb 2008
        • 121

        #4
        Originally posted by pentahari
        How to give the Common Error statement to all procedures and functions.

        My old code is
        [PHP]
        Sub sub1()
        On Error Resume Next
        statement.....
        End Sub

        Sub sub2()
        On Error Resume Next
        statement.....
        End Sub[/PHP]

        I always use error statement with in all procedures and functions, but i want one error statement handle all procedure errors.
        I'm still not sure what you want exactly, but maybe you want to have a class that collects the errors and messages?

        Comment

        • jeffstl
          Recognized Expert Contributor
          • Feb 2008
          • 432

          #5
          Originally posted by pentahari
          How to give the Common Error statement to all procedures and functions.

          My old code is
          [PHP]
          Sub sub1()
          On Error Resume Next
          statement.....
          End Sub

          Sub sub2()
          On Error Resume Next
          statement.....
          End Sub[/PHP]

          I always use error statement with in all procedures and functions, but i want one error statement handle all procedure errors.
          Then write one in your Module.

          Code:
          Sub sub1()
              On Error Resume Next
              MyErrorHandler
          End Sub
          
          Public Function MyErrorHandler
               dim myErrStr
               MyErrStr = "Error Number : " & Err.Number & " " Error Desc : " & Err.Description
          End Function
          If this doesn't answer your question then please say exactly what you are wondering

          Comment

          Working...