Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
tweak(errors): more precise wording with UnresIdnt
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed Jul 3, 2023
1 parent eb99df3 commit 0104154
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/model/errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ No `T` (opionally from `collection`) could be found that matches `identifier`.
```julia-repl
julia> d"iirs"
ERROR: UnresolveableIdentifier: "iirs" does not match any known data sets
ERROR: UnresolveableIdentifier: "iirs" does not match any availible data sets
Did you perhaps mean to refer to one of these data sets?
■:iris (75% match)
Stacktrace: [...]
julia> d"iris::Int"
ERROR: UnresolveableIdentifier: "iris::Int" does not match any known data sets
ERROR: UnresolveableIdentifier: "iris::Int" does not match any availible data sets
Without the type restriction, however, the following data sets match:
datatest:iris, which is availible as a DataFrame, Matrix, CSV.File
Stacktrace: [...]
Expand All @@ -31,7 +31,7 @@ UnresolveableIdentifier{T}(ident::I, collection::Union{DataCollection, Nothing}=

function Base.showerror(io::IO, err::UnresolveableIdentifier{DataSet, String})
print(io, "UnresolveableIdentifier: ", sprint(show, err.identifier),
" does not match any known data sets")
" does not match any availible data sets")
if !isnothing(err.collection)
print(io, " in ", sprint(show, err.collection.name))
end
Expand Down Expand Up @@ -416,3 +416,16 @@ function Base.showerror(io::IO, err::ImpossibleTypeException)
print(io, ", for unknown reasons, possibly an issue with the type parameters?")
end
end

struct InvalidParameterType{T <: Union{<:AbstractDataTransformer, DataSet, DataCollection}}
thing::T
parameter::String
type::Type
end

function Base.showerror(io::IO, err::InvalidParameterType)
print(io, "InvalidParameterType: '", err.parameter, "' parameter of ",
string(err.thing), " must be a ", string(err.type), " not a ",
string(typeof(get(err.thing, err.parameter))), ".")
# More info about `err.transformer` / parent dataset?
end

0 comments on commit 0104154

Please sign in to comment.