Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

When I create a method in vb.net, I can specify that the parameters passed are byVal or byRef. I tend to use the byRef when I want to return an error code if an exception is caught.

 

My question therefore is:

1. Is the use of byRef for passing error codes the correct approach? or is there a more effective approach especially if my functionis designed to return say a dataset?

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

  • Administrators
Posted

The best way to signal an error is just by using exceptions. If the routine you are calling has handled the error why does the calling routine need to know?

If on the other hand the called routine isn't handling the exception then it shouldn't be catching it.

 

As a rule you should use parameters for passing information into a routine and a return value for returning a result. If there is an unhandled error then signal this by either throwing an exception or just allowing the exception to propagate up the call stack.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...