Hey all,
I've seen a couple similar threads to this question, but none of them really answer the question I want to ask.
For starters, unfortunately I'm working with existing API code so sadly, while there may be a better way to do what I'm asking about, I'm locked in to doing it similarly to the way it is because backwards compatibility is non-negotiable.
I have a response class that currently contains an enum for an error code and a string description. The error codes define a fairly nice and complete set of responses that are all very semantically coupled to the operations where they're used.
Unfortuantely, I now have to add a different workflow for a similar set of API objects, and this will require a string description, which is fine, but also an enum error code consisting of a totally unrelated set of error codes. The error codes (and other aspects of the object model) will be used in lots of the same classes, so it would be nice to get a interface going so that i can run the objects through the same framework.
The intent here is to make a contract that says "I have an error code, and a description of that error code."
However, as far as I know there's no way to add an item to an interface such as
public interface IError
{
enum ErrorCode;
string Description;
}
nor is there a way to express
public interface IError<T> where T: enum
{
T ErrorCode;
string Description;
}
Anyone every run up against something like this before?