views:

37

answers:

2

Microsoft provides a bunch of standardized error codes for Windows (http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx). When applicable I find them useful to reference in my own applications, instead of creating my own. Is there something similar but specific to .NET?

+5  A: 

.NET discourages the use of error codes. Instead, focus on using, or deriving from, the standard Exception classes.

Exceptions should be preferred to error codes in .NET development.

Reed Copsey
OK, that makes sense. However, part of the reason we're doing this is for our service department; so they can have a list of all error codes/messages that the system can generate/throw. Given that, is there a better way than using string resources? Is there a way to do reflection (of exceptions or otherwise) to have a list of errors?
Ryan
Exceptions have the advantage of allowing the developer to provide context of the exception. You can include specific enum values for resources within custom exceptions, but also full text string explanations that help you narrow down where and what occurred.
Reed Copsey
Sure, I appreciate that. They just want a list of what can be encountered so they can review and ask questions before they have a customer on the phone. Maybe this should be posed as a separate question, but being able to get a list of potential error messages is still desirable.
Ryan
A: 

I agree with Reed Copsey, error codes are "remainings" from the past error handling methods.

The new way of doing i is Exception Handling.

Will Marcouiller