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

Where To Put Error Handling Code

P: n/a
Tom
Suppose you have code structure like this:
Option Explicit
Dim MyVariable As Single

Private Sub CallingProcedure()
Call CalledProcedure()
....Do This ...
End Sub

Private Sub CalledProcedure()
....Do That ....
MyVariable = 5/0
End Sub

Obviously there is an error in the CalledProcedure. Where is recommended to
put the error handling code and why? In the calling procedure or in the
called procedure.

Thanks!

Tom
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
>Obviously there is an error in the CalledProcedure. Where is recommended to
put the error handling code and why? In the calling procedure or in the
called procedure.


Both places is the place to put error handlers. In the called procedure
you should handle such things as missing variables, impossible values,
etc.

In the calling procedure, you put error handling to process things like
values out of range for the call, (sometimes a function call will
return a technically correct value that is out of range for your
calling procedure) etc.

In summary, handle errors at the lowest possible level, that way your
code is much more maintainable and transportable.

Q.

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.