I want this so badly, please implement

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 7 08:35:31 PDT 2016


On Thursday, 7 April 2016 at 09:31:15 UTC, Kagamin wrote:
> How do you spend time on it?

A program dies with a RangeError. I don't know why because it 
doesn't tell me any useful information about the failing data. 
This is quite frustrating because that information is available 
and trivial to attach to the object, but it is just dropped.

What I'd actually do in a perfect world is attach the whole array 
to the object:

class RangeError : Error {}
class TypedRangeError(T) : RangeError {
    T[] slice;
    size_t attemptedIndex;
    override string toString() { /* print the above in some 
human-readable way */ }
}


Because then I can see what runtime data specifically caused the 
problem.


But like I said about AAs, adding an array is harder, so I'm 
happy with just the numbers as a compromise - at least then I can 
see what part of the loop is the problem instead of just the line 
of code.



The time sink comes when processing a million items and seeing a 
random RangeError in the middle of processing. file.d:6 is great, 
but which one of the million lines of DATA was the problem? At 
least giving me the index and length narrows that down.

I typically go back and edit the source to print out some kind of 
log info, then wait for it to all run again. Just a frustration - 
one of the few I face regularly in D.


More information about the Digitalmars-d mailing list