julia icon indicating copy to clipboard operation
julia copied to clipboard

Error message improvement for BoundsError: Print the exact problem indexes

Open BioTurboNick opened this issue 3 years ago • 4 comments

Resolves #40747

Before:

[1,2,3][[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,]]
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1  …  2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]

After:

[1,2,3][[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,]]
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index [5] in [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1  …  2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]

And a more complex example:

[1 2 3; 4 5 6][2:10, collect(1:10), 4]
ERROR: BoundsError: attempt to access 2×3 Matrix{Int64} at index [3:10, [4, 5, 6, 7, 8, 9, 10], 4] in [2:10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 4]

BioTurboNick avatar May 07 '21 20:05 BioTurboNick