In many industry systems, we need to log the error and then throw a new exception with the same message. The logger will populate the message with markers and variables.
But we need to manually populated it by string + again when construct the exception message. This is an anti-pattern.
Please take below snippet as example:
If the API can return populated message, the code would turn much better:
The only concern is that this may only works for synchronous logging, not work for asynchronous way. But I believe it could be resolved.