In theory, the end user should never see internal errors. But in practice, theory and practice are different. Therefore, the question is to show the end user. Now, for a completely non-technical user, you want to show as little as possible ("click here to send an error report"), but for more advanced users they will want to know if there is work if it has been known for some time, etc. d. Therefore, you want to include some information about what is wrong.
The classic way to do this is either a statement with a file name: a line number or a stack trace with the same. Now this is good for the developer, because he directly points to the problem; however, it has some significant drawbacks for the user, in particular, that he is very mysterious (for example, unfriendly) and changes to the code change the error message (only Google works for errors for this version).
I have a program that I plan to write where I want to solve these problems. What I want is a way to give a unique identity to each statement in such a way that editing the code around the statement will not change it. (For example, if I cut / paste it into another file, I want the same information to be displayed) Any ideas?
One of the ways I'm thinking about is to list the errors, but how to make sure they are never used in more than one place?
(Note: for this question, I only consider errors caused by coding errors. Not something that can legitimately happen as bad input. OTOH, these errors may be of some interest to the community as a whole.)
(Note 2: the program in question will be a command-line application running on the user system. But then again, this is just my situation.)
(Note 3: the target language is D and I really want to dive into metaprogramming . Answers to other languages are more than welcome!)
(Note 4: I clearly want NOT to use the actual code locations, but rather some symbolic names for errors. This is because if the code changes in almost any way, the code locations change.)