Skip to content

Informative error message at macro eval time for extra arguments #48

@tpapp

Description

@tpapp

If condition does not fail, @argcheck condition b c does not error even though it is invalid:

julia> @argcheck 1 == 1 1.8 "That's good"

However, for !condition, users get a confusing error message:

julia> @argcheck 1 == 2 1.8 "That's bad"
ERROR: MethodError: no method matching build_error(::ArgCheck.CallErrorInfo, ::ArgCheck.ArgCheckFlavor, ::Float64, ::String)
The function `build_error` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  build_error(::Any, ::Any)
   @ ArgCheck ~/.julia/packages/ArgCheck/D1ZFJ/src/checks.jl:294
  build_error(::Any, ::Any, ::Exception)
   @ ArgCheck ~/.julia/packages/ArgCheck/D1ZFJ/src/checks.jl:299
  build_error(::Any, ::Any, ::Type{<:Exception})
   @ ArgCheck ~/.julia/packages/ArgCheck/D1ZFJ/src/checks.jl:294
  ...

Stacktrace:
 [1] build_error(info::ArgCheck.CallErrorInfo)
   @ ArgCheck ~/.julia/packages/ArgCheck/D1ZFJ/src/checks.jl:287
 [2] throw_check_error(info::Any)
   @ ArgCheck ~/.julia/packages/ArgCheck/D1ZFJ/src/checks.jl:279
 [3] top-level scope
   @ REPL[67]:1

Version [dce04be8] ArgCheck v2.4.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions