From: Sandro M. <naa...@gm...> - 2006-05-26 21:02:45
|
On 5/26/06, Tyler Close <tyl...@gm...> wrote: > There is no requirement that the error enumeration be exhaustive. This > list of errors is just saying: "Here's a list of errors I might return > and that you might want to treat specially. I might also return some > other kind of error, and you'll just have to cope with that using a > generic error handling strategy." In a mutually suspicious, > distributed setting, a client can't rely on a server only returning > certain kinds of errors, so an error list can only be advisory. Well that's a relief. :-) > The errors are not mandatory, but they are very useful when writing > client code, if some errors should be handled in different ways. > Surely there must be some way in C# for an object to tell its clients > about different kinds of errors they might want to handle? Documentation. As with javadoc comments, there is a section for declaring exceptions, but obviously this is dependent on the developer taking the time to fill it in. > > However, this is very error-prone and the developer will likely miss > > exceptions; exceptions thrown from underlying method calls will be the > > most likely culprits. > > Go with whatever the convention is in C# for documenting the errors > returned by a method. These are not programmatically accessible however, so the dynamic serialization of a method will not contain an error enumeration. I would have to devise some strategy to extract the declared exceptions from the comments, or as I first suggested, have the user declare the exceptions via attributes decorating the methods. Sandro |