Re: methods and returned values
Marc Brooks <[email protected]> Fri, 27 Oct 2006 11:09:41 -0500
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <[email protected]> |
> > What is the best way around this (besides duplicating all the code to create
> > and throw the derived exception in each of the methods)?
I'm going off the board for:
c) Construct the exception in a seperate method and return it to the
else clause:
if (foo.IsValid())
{
foo.Fun().Fun().Fun();
}
else
{
throw ConstructBadFoo(foo);
}
private /* static */ Exception BadFoo(Customer foo)
{
reutrn new CustomerException("thing are dark and damp here", foo.ID);
}
--
"We do not have the luxury of making that risky assumption that people
will not be affected by the potential change. I know this can be
frustrating for you as it is for us. Thanks for your understanding in
this matter.." --Some misguided soul at Microsoft
Marc C. Brooks
http://musingmarc.blogspot.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com