Re: methods and returned values
Peter Osucha <[email protected]> Fri, 27 Oct 2006 12:20:50 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <!&!AAAAAAAAAAAYAAAAAAAAAJQbbsu8SIRPt28l5GlqTHTCgAAAEAAAABZD7+MRvg9PpbT5bg7naDgBAAAAAA==@comcast.net> |
All good solutions (I actually have been doing the one Alan noted though honestly, I like the others better). Thanks guys. Peter -----Original Message----- From: Discussion relating to the specifics of the C# and Managed C++ languages [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Friday, October 27, 2006 11:16 AM To: [email protected] Subject: [DOTNET-CX] methods and returned values OK - sorry for the dumb question but... I have a bunch of methods that are set up to return values of type MyObj. In virtually all of the methods, there is an if...else construct so that if a condition isn't met for returning a valid MyObj, a derived exception can be raised with info as to what the problem was. So I decided to create a private method that would generate the exception and then throw it which I would call from the 'else' block of all the methods described above. This isn't legal, however, since I then get an error that not all code paths return a value (namely, the 'else' block which call the private method to throw the error. What is the best way around this (besides duplicating all the code to create and throw the derived exception in each of the methods)? Peter =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com