I have overridden (replaced) dofile in order to make it use only paths relative to the application. If within that dofile an exception is thrown (ie FileNotFound), I always got an IndexOutOfBoundsException.
I investigated, built the project with PDB, and found the culprit to be in the Traceback class' LastPosition getter. Near the end, it returns one of the indexes of SourcePositions:
var p = closure.Proto;
return p.SourcePositions[frame.CallerInstructionIndex];
It seems that frame.CallerInstructionIndex is negative in my case (I have not further investigated as to why). I would suggest to add an in-range check, this fixed the issue for me and since then I get proper error messages:
var p = closure.Proto;
if (frame.CallerInstructionIndex >= 0 && frame.CallerInstructionIndex < p.SourcePositions.Length)
return p.SourcePositions[frame.CallerInstructionIndex];