andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
282 stars 28 forks source link

Do not print arbitrary-length datastructures in error messages #61

Closed jakobnissen closed 3 years ago

jakobnissen commented 3 years ago

Right now, if you access an Indices with a wrong index, you get a helpful error message:

julia> Indices(1:3)[4]
ERROR: IndexError("Index 4 not found in indices {1, 2, 3}")

However, the error message is not so helpful if your datastructure is large:

julia> Indices(1:3000)[4000]
ERROR: IndexError("Index 4000 not found in indices {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,

[ etc etc etc]

It's probably better to avoid interpolating these datastructures into the error strings.

andyferris commented 3 years ago

I agree. Maybe we can put a :limit = true around that, though.