Is something along these lines possible? Using Visual Studio (and it's kind of language agnostic I guess but I am using C#), precompiling, I would like to somehow inject and replace values with a unique ID (or number is fine!).
E.g.
public void HelloWorld (
{
{VARIABLE_FOR_UNIQUE_ID_REPLACED_AT_COMPILE_TIME}
var someVar = "Error Code#";
console.print(someVar + {VARIABLE_FOR_UNIQUE_ID_REPLACED_AT_COMPILE_TIME})
}
So for every function, I will have {VARIABLE_FOR_UNIQUE_ID_REPLACED_AT_COMPILE_TIME} and it will be a unique ID to that function, in every file, throughout the solution. It doesn't need to be anything complicated like a GUID, ideally it is just an incremental number when added but does not change after adding. This number is used to identify the function for Error Codes - so I can track where the error derived from even though the message is a generic "something went wrong", e.g. "Error Code #445 something went wrong", "Error Code #6778 something went wrong".
I think you should manage that yourself.
Think about it:
If you get error reports in saying "Error Code #445 something went wrong" then first thing you will want to do is search your code base for "445" to find the originating code - but you won't find anything with the scheme you are describing since the actual source of the error will just say {VARIABLE_FOR_UNIQUE_ID_REPLACED_AT_COMPILE_TIME}.
If on the other hand you just manage it yourself and write something like:
...and always keep that same pattern in your code, then in a debug situation where you need to find 445 you can actually search your code base for 445 and find the place where the error is coming from.