By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

Error Handling

pentahari
P: 60
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]
May 19 '08 #1
Share this Question
Share on Google+
4 Replies


jeffstl
Expert 100+
P: 432
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:

Expand|Select|Wrap|Line Numbers
  1. Public Function ReadTable(MyParameter) as Variant
  2. On Error GoTo Error_ReadTable
  3.      'normal code
  4.  
  5. Error_ReadTable:
  6.      'error handling code
  7.      'call a write function or format function 
  8.      'to display error or log error
  9. End Function
  10.  
I would be more specific but I don't know what your looking for.
May 19 '08 #2

pentahari
P: 60
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.
May 20 '08 #3

100+
P: 121
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?
May 20 '08 #4

jeffstl
Expert 100+
P: 432
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.

Expand|Select|Wrap|Line Numbers
  1. Sub sub1()
  2.     On Error Resume Next
  3.     MyErrorHandler
  4. End Sub
  5.  
  6. Public Function MyErrorHandler
  7.      dim myErrStr
  8.      MyErrStr = "Error Number : " & Err.Number & " " Error Desc : " & Err.Description
  9. End Function
  10.  
If this doesn't answer your question then please say exactly what you are wondering
May 20 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.