I have two contructors that are conflicting and I don't know how I could handle this situation.
public NotFoundError(string name, object key, int code = 0)
: base($"Entity '{name}' ({key}) was not found.")
{
Code = code;
}
public NotFoundError(string message, int code = 0)
: base(message)
{
Code = code;
}
If I do the following:
throw new NotFoundError(nameof(Customer), request.Id);
It picks the second constructor instead of the first. I know that it happens because it could match with either of them. However, I would like to keep the first constructor because in 99% of the cases, the message will look like that and I don't want to add the message to every exception. For both cases I need the ability to overwrite the error code.