Proper way to pass a catch back to the parent page.

D

darrel

I have a .aspx.vb page that calls a function in a .vb file that has a try
catch.

Usually, I use a catch to display an error. In this case, I want the parent
page to know if the function errors out or now. What's the proper method to
pass this information back to the page?

For insance, here's my aspx.vb page:
------------------------
myFunction()
------------------------

and my .vb class:
------------------------
function myFunction()
try
this
catch
show error
end try
end myFunction
 
S

Steve C. Orr [MVP, MCSD]

You could rethrow the error as Karl mentioned, or you could have your
function return a parameter that signifies an error, which would likely have
better performance.
Something like this:

function bool myFunction()
try
this;
return false; //no error
catch
show error;
return true; //true signals error
end try
end myFunction
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top