4 ms·
Can you give some examples of errors that should be thrown upwards? What percentage of errors in a program belong to this group?
by markessien 18y ago
Can you give some examples of errors that should be thrown upwards? What percentage of errors in a program belong to this group?
- scott_s 18y agoThe most obvious to me is when you know something should be one of a finite set of values, and its actual value is not in that set. In my compiler, I have to classify array accesses as either a row or a column access. After a certain point, if it's neither (unitialized), then it's a serious error, I can't continue, and I throw an exception. I have similar situations when I deduce the types of an expression. Since I perform transformations on code, I also expect to find certain variables at certain places - if I can't find it anywhere, then I throw an exception. Some of these are exceptions that I can recover from in that while the compilation is broken, I can still continue to find more errors. Others are show stoppers. I encounter these kinds of errors every time I have to do any decision based on these properties, which is often.