mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
[other] better error message for IndexError for empty containers (#11476)
(cherry picked from commit b3d2cd738a)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user