Decision:
Keep error messages with named placeholders, for example:
- "This is a mistake {name1}. Andkg kfkjgkf {name2}"
- "this is a problem {size}"
Then you need a class that accepts a message with a raw message like "this is a problem {size}" in its constructor.
Then the class will allow the developer to specify values for each of the placeholders.
Finally, the developer will call a method that replaces the placeholders with the specified values and returns the result.
i.e.
var rawMessage = "this is some {size} problem";
var errorMessage = new ErrorMessage(rawMessage);
errorMessage.SetPlaceholderValue("size", "big");
var message = errorMessage.BuildErrorMessage();
source
share