[other] better error message for IndexError for empty containers (#11476)

(cherry picked from commit b3d2cd738a)
This commit is contained in:
Miran
2019-06-11 14:34:21 +02:00
committed by narimiran
parent 8dfebb3282
commit 65a2b3bb6f

View File

@@ -4,7 +4,8 @@ template formatErrorIndexBound*[T](i, a, b: T): string =
when defined(standalone):
"indexOutOfBounds"
else:
"index " & $i & " not in " & $a & " .. " & $b
if b < a: "index out of bounds, the container is empty"
else: "index " & $i & " not in " & $a & " .. " & $b
template formatErrorIndexBound*[T](i, n: T): string =
formatErrorIndexBound(i, 0, n)