Skip to content

Commit

Permalink
improve error message when used selector is incorrect (#3242)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins authored Dec 25, 2022
1 parent be13650 commit d67e3a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/other/index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,20 @@ end
if all(x -> x isa Symbol, idxs)
return getindex(x, convert(Vector{Symbol}, idxs))
else
throw(ArgumentError("mixing `Symbol`s with other selectors is not allowed"))
throw(ArgumentError("mixing `Symbol`s with other selectors in a vector " *
"is not allowed. Maybe you wanted to use `Cols` instead?"))
end
elseif idxs[1] isa AbstractString
if all(x -> x isa AbstractString, idxs)
return getindex(x, Symbol.(idxs))
else
throw(ArgumentError("mixing strings with other selectors is not allowed"))
throw(ArgumentError("mixing `Symbol`s with other selectors in a vector " *
"is not allowed. Maybe you wanted to use `Cols` instead?"))
end
end
throw(ArgumentError("idxs[1] has type $(typeof(idxs[1])); only Integer, Symbol, "*
"or string values allowed when indexing by vector"))
"or string values allowed when indexing by vector. " *
"Maybe you wanted to use `Cols` instead?"))
end

@inline Base.getindex(x::AbstractIndex, rx::Regex) =
Expand Down

0 comments on commit d67e3a7

Please sign in to comment.