Throwing exceptions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I would like to know the general procedure to throw exceptions. Lets say
I have a datagrid in my webpage and I am pulling the data for my webpage
using a function. The function accepts parameter CompanyId and returns
datatable. If I pass an empty CompanyId from the webpage, the function
should throw an exception saying "CompanyId is empty". If I pass a Valid
CompanyId, it should return datatable. So how can we return multiple data
typed values from the same function?

Please let me know.

Thanks,
Sridhar.
 
Throwing exceptions stops execution. So, if you throw an exception, the
exception is not "returned" from the method, but "thrown" by it. Therefore,
when an exception is thrown, nothing is returned from the method. The method
simply doesn't return.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
 
Sridhar,

When you throw an exception inside your function, the function doesn't
return a value in a regular way. The whole chain of the code execution
breaks. The function won't finish and the next code to execute will be your
catch block if you have any. If you don't, you will get a message about an
unhandled exception.

Eliyahu
 
Back
Top