Skip to content

Commit

Permalink
Merge pull request #62 from jakobnissen/indexerror
Browse files Browse the repository at this point in the history
Set :limit=>true for index erors
  • Loading branch information
andyferris authored Aug 15, 2021
2 parents 26d1be0 + 082983b commit 985459b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/AbstractIndices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,16 @@ end

function Base.checkindex(indices::AbstractIndices{I}, i::I) where {I}
if i indices
throw(IndexError("Index $i not found in indices $indices"))
short_ind = repr(indices, context=:limit => true)
throw(IndexError("Index $i not found in indices $short_ind"))
end
end
Base.checkindex(indices::AbstractIndices{I}, i) where {I} = checkindex(indices, convert(I, i))

function checkindices(indices::AbstractIndices, inds)
if !(inds indices)
throw(IndexError("Indices $inds are not a subset of $indices"))
short_ind = repr(indices, context=:limit => true)
throw(IndexError("Indices $inds are not a subset of $short_ind"))
end
end

Expand Down Expand Up @@ -346,4 +348,4 @@ end
end
else
@deprecate disjoint(set1, set2) isdisjoint(set1, set2)
end
end

0 comments on commit 985459b

Please sign in to comment.