Troubleshoot -1 index. Found the exact location where it happens.

Actually the error was confusing, in my case it has happened when the
subs index is greater than length of the string (so -1 was confusing).